aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2017-06-12 04:07:30 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2017-06-12 04:07:30 +0300
commitf446a04e4100ed52e9d100e8e9705d358943a4ec (patch)
tree40ce78f56691dd85fe98b406b7de1b2c3b1d7551
parentsetenv: crap, another bug (diff)
downloadwindows-env-f446a04e4100ed52e9d100e8e9705d358943a4ec.tar.gz
windows-env-f446a04e4100ed52e9d100e8e9705d358943a4ec.zip
refactoring
-rw-r--r--app/ListPaths.hs4
-rw-r--r--app/RemovePath.hs3
-rw-r--r--app/SetEnv.hs5
-rw-r--r--app/UnsetEnv.hs10
4 files changed, 11 insertions, 11 deletions
diff --git a/app/ListPaths.hs b/app/ListPaths.hs
index c507d39..0c8483c 100644
--- a/app/ListPaths.hs
+++ b/app/ListPaths.hs
@@ -70,7 +70,9 @@ listPaths options = runExceptT doListPaths >>= either ioError return
query = queryFrom $ optSource options
- queryFrom Environment = lift $ WindowsEnv.Value False <$> fromMaybe "" <$> lookupEnv varName
+ queryFrom Environment = lift $ WindowsEnv.Value False
+ <$> fromMaybe ""
+ <$> lookupEnv varName
queryFrom (Registry profile) = WindowsEnv.query profile varName
doListPaths = do
diff --git a/app/RemovePath.hs b/app/RemovePath.hs
index a8bf56d..56ea66f 100644
--- a/app/RemovePath.hs
+++ b/app/RemovePath.hs
@@ -72,7 +72,8 @@ removePath options = runExceptT doRemovePath >>= either ioError return
removePathFrom profile = do
oldValue <- WindowsEnv.query profile varName
let expandable = WindowsEnv.valueExpandable oldValue
- let split = WindowsEnv.pathSplit $ WindowsEnv.valueString oldValue
+ let joined = WindowsEnv.valueString oldValue
+ let split = WindowsEnv.pathSplit joined
let remaining = filter (flip notElem pathsToRemove) split
when (length split /= length remaining) $ do
let newValue = WindowsEnv.Value expandable (WindowsEnv.pathJoin remaining)
diff --git a/app/SetEnv.hs b/app/SetEnv.hs
index e77b05a..6932198 100644
--- a/app/SetEnv.hs
+++ b/app/SetEnv.hs
@@ -56,14 +56,13 @@ setEnv options = runExceptT doSetEnv >>= either ioError return
where
varName = optName options
varValue = optValue options
-
forAllUsers = optGlobal options
+ skipPrompt = optYes options
+
profile
| forAllUsers = WindowsEnv.AllUsers
| otherwise = WindowsEnv.CurrentUser
- skipPrompt = optYes options
-
doSetEnv = do
expanded <- WindowsEnv.expand varValue
let expandable = expanded /= varValue
diff --git a/app/UnsetEnv.hs b/app/UnsetEnv.hs
index 02df1a1..b841f86 100644
--- a/app/UnsetEnv.hs
+++ b/app/UnsetEnv.hs
@@ -50,17 +50,15 @@ unsetEnv :: Options -> IO ()
unsetEnv options = runExceptT doUnsetEnv >>= either ioError return
where
varName = optName options
-
forAllUsers = optGlobal options
+ skipPrompt = optYes options
+
profile
| forAllUsers = WindowsEnv.AllUsers
| otherwise = WindowsEnv.CurrentUser
- skipPrompt = optYes options
+ doUnsetEnv = void $ promptAnd $ WindowsEnv.wipe profile varName
+
promptAnd
| skipPrompt = withoutPrompt
| otherwise = withPrompt $ wipeMessage profile varName
-
- wipe = WindowsEnv.wipe profile varName
-
- doUnsetEnv = void $ promptAnd wipe