diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-07-12 17:10:29 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-07-12 17:10:29 +0300 |
commit | c7d5766463e5e99fcd2352c7177cf057c1971615 (patch) | |
tree | 04e2c34217dd498111965a17b9cafcb633ed5c13 /apps/ListPath.hs | |
parent | minimize stack.yaml (diff) | |
download | windows-env-c7d5766463e5e99fcd2352c7177cf057c1971615.tar.gz windows-env-c7d5766463e5e99fcd2352c7177cf057c1971615.zip |
refactoring
Diffstat (limited to 'apps/ListPath.hs')
-rw-r--r-- | apps/ListPath.hs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/apps/ListPath.hs b/apps/ListPath.hs index 95d9c8b..63460b9 100644 --- a/apps/ListPath.hs +++ b/apps/ListPath.hs @@ -6,7 +6,10 @@ module Main (main) where -import System.Directory (doesDirectoryExist) +import Control.Monad (liftM) +import Data.Maybe (fromMaybe) +import System.Directory (doesDirectoryExist) +import System.Environment (lookupEnv) import Options.Applicative @@ -29,10 +32,13 @@ main = execParser parser >>= listPath parser = info (helper <*> options) $ fullDesc <> progDesc "List directories in your PATH" +getEnv :: String -> IO String +getEnv = liftM (fromMaybe "") . lookupEnv + listPath :: Options -> IO () listPath options = do - val <- Environment.getEnv $ name options - mapM_ printPath $ Environment.splitPaths val + val <- getEnv $ name options + mapM_ printPath $ Environment.pathSplit val where printPath p = do exists <- doesDirectoryExist p |