aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apps/ListPath.hs
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-07-12 17:10:29 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-07-12 17:10:29 +0300
commitc7d5766463e5e99fcd2352c7177cf057c1971615 (patch)
tree04e2c34217dd498111965a17b9cafcb633ed5c13 /apps/ListPath.hs
parentminimize stack.yaml (diff)
downloadwindows-env-c7d5766463e5e99fcd2352c7177cf057c1971615.tar.gz
windows-env-c7d5766463e5e99fcd2352c7177cf057c1971615.zip
refactoring
Diffstat (limited to '')
-rw-r--r--apps/ListPath.hs12
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