diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2017-06-11 05:56:10 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2017-06-11 05:56:10 +0300 |
commit | 837e60b9d8826168896ad4155ff7046f00665f52 (patch) | |
tree | 18c40efee9f38954079119587d3b60ababf5e555 /app | |
parent | delenv: ignore missing variables (diff) | |
download | windows-env-837e60b9d8826168896ad4155ff7046f00665f52.tar.gz windows-env-837e60b9d8826168896ad4155ff7046f00665f52.zip |
WindowsEnv: {VarName,VarValue} -> {Name,Value}
Also, fix compiler warnings (I've got too used to building with
`--ghc-options -w`).
Diffstat (limited to '')
-rw-r--r-- | app/AddPath.hs | 8 | ||||
-rw-r--r-- | app/ListPaths.hs | 8 | ||||
-rw-r--r-- | app/RemovePath.hs | 8 | ||||
-rw-r--r-- | app/SetEnv.hs | 4 | ||||
-rw-r--r-- | app/UnsetEnv.hs | 2 | ||||
-rw-r--r-- | app/Utils/PromptMessage.hs | 12 |
6 files changed, 21 insertions, 21 deletions
diff --git a/app/AddPath.hs b/app/AddPath.hs index ff80b18..d141270 100644 --- a/app/AddPath.hs +++ b/app/AddPath.hs @@ -20,7 +20,7 @@ import Utils.Prompt import Utils.PromptMessage data Options = Options - { optName :: WindowsEnv.VarName + { optName :: WindowsEnv.Name , optYes :: Bool , optGlobal :: Bool , optPrepend :: Bool @@ -83,15 +83,15 @@ addPath options = runExceptT doAddPath >>= either ioError return defaultValue = do expandedPaths <- mapM WindowsEnv.expand pathsToAdd if pathsToAdd == expandedPaths - then return $ WindowsEnv.VarValue False "" - else return $ WindowsEnv.VarValue True "" + then return $ WindowsEnv.Value False "" + else return $ WindowsEnv.Value True "" doAddPath = do oldValue <- WindowsEnv.query profile varName `catchE` emptyIfMissing let oldPaths = WindowsEnv.pathSplit $ show oldValue let newPaths = pathsToAdd \\ oldPaths unless (null newPaths) $ do - let newValue = WindowsEnv.VarValue (WindowsEnv.varValueExpandable oldValue) $ WindowsEnv.pathJoin (mergePaths oldPaths newPaths) + let newValue = WindowsEnv.Value (WindowsEnv.valueExpandable oldValue) $ WindowsEnv.pathJoin (mergePaths oldPaths newPaths) promptAndEngrave oldValue newValue promptAndEngrave oldValue newValue = do diff --git a/app/ListPaths.hs b/app/ListPaths.hs index f832686..c507d39 100644 --- a/app/ListPaths.hs +++ b/app/ListPaths.hs @@ -30,7 +30,7 @@ data Source = Environment | Registry WindowsEnv.Profile deriving (Eq, Show) data Options = Options - { optName :: WindowsEnv.VarName + { optName :: WindowsEnv.Name , optWhichPaths :: WhichPaths , optSource :: Source } deriving (Eq, Show) @@ -70,12 +70,12 @@ listPaths options = runExceptT doListPaths >>= either ioError return query = queryFrom $ optSource options - queryFrom Environment = lift $ WindowsEnv.VarValue False <$> fromMaybe "" <$> lookupEnv varName + queryFrom Environment = lift $ WindowsEnv.Value False <$> fromMaybe "" <$> lookupEnv varName queryFrom (Registry profile) = WindowsEnv.query profile varName doListPaths = do - value <- query - split <- WindowsEnv.pathSplitAndExpand value + varValue <- query + split <- WindowsEnv.pathSplitAndExpand varValue lift $ do wanted <- filterM (shouldListPath whichPaths) split mapM_ (putStrLn . WindowsEnv.pathOriginal) wanted diff --git a/app/RemovePath.hs b/app/RemovePath.hs index 23cabb7..7157100 100644 --- a/app/RemovePath.hs +++ b/app/RemovePath.hs @@ -19,7 +19,7 @@ import Utils.Prompt import Utils.PromptMessage data Options = Options - { optName :: WindowsEnv.VarName + { optName :: WindowsEnv.Name , optYes :: Bool , optGlobal :: Bool , optPaths :: [String] @@ -69,8 +69,8 @@ removePath options = runExceptT doRemovePath >>= either ioError return defaultValue = do expandedPaths <- mapM WindowsEnv.expand pathsToRemove if pathsToRemove == expandedPaths - then return $ WindowsEnv.VarValue False "" - else return $ WindowsEnv.VarValue True "" + then return $ WindowsEnv.Value False "" + else return $ WindowsEnv.Value True "" doRemovePath = do removePathFrom WindowsEnv.CurrentUser @@ -82,7 +82,7 @@ removePath options = runExceptT doRemovePath >>= either ioError return let oldPaths = WindowsEnv.pathSplit $ show oldValue let newPaths = filter (flip notElem pathsToRemove) oldPaths when (length oldPaths /= length newPaths) $ do - let newValue = WindowsEnv.VarValue (WindowsEnv.varValueExpandable oldValue) (WindowsEnv.pathJoin newPaths) + let newValue = WindowsEnv.Value (WindowsEnv.valueExpandable oldValue) (WindowsEnv.pathJoin newPaths) let promptAnd = if skipPrompt then withoutPrompt else withPrompt $ oldNewMessage profile varName oldValue newValue diff --git a/app/SetEnv.hs b/app/SetEnv.hs index a986226..d590f64 100644 --- a/app/SetEnv.hs +++ b/app/SetEnv.hs @@ -21,7 +21,7 @@ import Utils.PromptMessage data Options = Options { optYes :: Bool , optGlobal :: Bool - , optName :: WindowsEnv.VarName + , optName :: WindowsEnv.Name , optValue :: String } deriving (Eq, Show) @@ -55,7 +55,7 @@ setEnv :: Options -> IO () setEnv options = runExceptT doSetEnv >>= either ioError return where varName = optName options - varValue = WindowsEnv.VarValue False $ optValue options + varValue = WindowsEnv.Value False $ optValue options forAllUsers = optGlobal options profile diff --git a/app/UnsetEnv.hs b/app/UnsetEnv.hs index 98b52e3..02df1a1 100644 --- a/app/UnsetEnv.hs +++ b/app/UnsetEnv.hs @@ -21,7 +21,7 @@ import Utils.PromptMessage data Options = Options { optYes :: Bool , optGlobal :: Bool - , optName :: WindowsEnv.VarName + , optName :: WindowsEnv.Name } deriving (Eq, Show) optionParser :: Parser Options diff --git a/app/Utils/PromptMessage.hs b/app/Utils/PromptMessage.hs index 1315b85..609cb8f 100644 --- a/app/Utils/PromptMessage.hs +++ b/app/Utils/PromptMessage.hs @@ -15,24 +15,24 @@ import Text.Printf (printf) import qualified WindowsEnv -oldNewMessage :: WindowsEnv.Profile -> WindowsEnv.VarName -> WindowsEnv.VarValue -> WindowsEnv.VarValue -> String +oldNewMessage :: WindowsEnv.Profile -> WindowsEnv.Name -> WindowsEnv.Value -> WindowsEnv.Value -> String oldNewMessage profile name oldValue newValue = descrMsg ++ oldValueMsg ++ newValueMsg where profileKey = WindowsEnv.profileKeyPath profile descrMsg = printf "Saving variable '%s' to '%s'...\n" name $ show profileKey - oldValueMsg = printf "\tOld value: %s\n" $ WindowsEnv.varValueString oldValue - newValueMsg = printf "\tNew value: %s\n" $ WindowsEnv.varValueString newValue + oldValueMsg = printf "\tOld value: %s\n" $ WindowsEnv.valueString oldValue + newValueMsg = printf "\tNew value: %s\n" $ WindowsEnv.valueString newValue -newMessage :: WindowsEnv.Profile -> WindowsEnv.VarName -> WindowsEnv.VarValue -> String +newMessage :: WindowsEnv.Profile -> WindowsEnv.Name -> WindowsEnv.Value -> String newMessage profile name newValue = descrMsg ++ newValueMsg where profileKey = WindowsEnv.profileKeyPath profile descrMsg = printf "Saving variable '%s' to '%s'...\n" name $ show profileKey - newValueMsg = printf "\tNew value: %s\n" $ WindowsEnv.varValueString newValue + newValueMsg = printf "\tNew value: %s\n" $ WindowsEnv.valueString newValue -wipeMessage :: WindowsEnv.Profile -> WindowsEnv.VarName -> String +wipeMessage :: WindowsEnv.Profile -> WindowsEnv.Name -> String wipeMessage profile name = printf "Deleting variable '%s' from '%s'...\n" name $ show profileKey where |