diff options
Diffstat (limited to '')
-rw-r--r-- | app/ListPaths.hs | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/app/ListPaths.hs b/app/ListPaths.hs index 5834f11..4193ad6 100644 --- a/app/ListPaths.hs +++ b/app/ListPaths.hs @@ -9,7 +9,7 @@ module Main (main) where import Control.Monad (filterM) import Control.Monad.Trans.Class (lift) -import Control.Monad.Trans.Except (ExceptT, runExceptT) +import Control.Monad.Trans.Except (runExceptT) import Data.Maybe (fromMaybe) import System.Directory (doesDirectoryExist) import System.Environment (lookupEnv) @@ -63,23 +63,6 @@ main = execParser parser >>= listPaths parser = info (helper <*> optionParser) $ fullDesc <> progDesc "List directories in your PATH" -data ExpandedPath = ExpandedPath - { pathOriginal :: WindowsEnv.VarValue - , pathExpanded :: WindowsEnv.VarValue - } deriving (Eq, Show) - -splitAndExpand :: WindowsEnv.VarValue -> ExceptT IOError IO [ExpandedPath] -splitAndExpand pathValue = do - expandedOnce <- expandOnce - zipWith ExpandedPath originalPaths <$> - if length expandedOnce == length originalPaths - then return expandedOnce - else expandEach - where - originalPaths = WindowsEnv.pathSplit pathValue - expandOnce = WindowsEnv.pathSplit <$> WindowsEnv.expand pathValue - expandEach = mapM WindowsEnv.expand originalPaths - listPaths :: Options -> IO () listPaths options = runExceptT doListPaths >>= either ioError return where @@ -91,10 +74,10 @@ listPaths options = runExceptT doListPaths >>= either ioError return queryFrom Environment = lift $ fromMaybe "" <$> lookupEnv varName queryFrom (Registry profile) = WindowsEnv.query profile varName - filterPaths = filterM (shouldListPath whichPaths . pathExpanded) + filterPaths = filterM (shouldListPath whichPaths . WindowsEnv.pathExpanded) doListPaths = do - paths <- query >>= splitAndExpand + paths <- query >>= WindowsEnv.pathSplitAndExpand lift $ do pathsToPrint <- filterPaths paths - mapM_ (putStrLn . pathOriginal) pathsToPrint + mapM_ (putStrLn . WindowsEnv.pathOriginal) pathsToPrint |