aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/AddPath.hs12
-rw-r--r--apps/FixNtSymbolPath.hs14
-rw-r--r--apps/ListPath.hs12
-rw-r--r--apps/RemovePath.hs12
-rw-r--r--apps/SetEnv.hs6
-rw-r--r--apps/UnsetEnv.hs6
6 files changed, 34 insertions, 28 deletions
diff --git a/apps/AddPath.hs b/apps/AddPath.hs
index 85f2aa4..5203723 100644
--- a/apps/AddPath.hs
+++ b/apps/AddPath.hs
@@ -44,11 +44,11 @@ addPath :: Options -> IO ()
addPath options = do
missingPaths <- dropIncludedPaths $ paths options
when (not $ null missingPaths) $ do
- oldPath <- Environment.queryFromRegistry env $ name options
- Environment.saveToRegistryWithPrompt env (name options) $ Environment.joinPaths $ missingPaths ++ [oldPath]
+ oldPath <- Environment.query env $ name options
+ Environment.engraveWithPrompt env (name options) $ Environment.pathJoin $ missingPaths ++ [oldPath]
where
dropIncludedPaths paths = do
- currentPath <- Environment.getEnv $ name options
- return $ filter (flip notElem $ Environment.splitPaths currentPath) paths
- env | global options = Environment.AllUsersEnvironment
- | otherwise = Environment.CurrentUserEnvironment
+ currentPath <- Environment.query env $ name options
+ return $ filter (flip notElem $ Environment.pathSplit currentPath) paths
+ env | global options = Environment.AllUsers
+ | otherwise = Environment.CurrentUser
diff --git a/apps/FixNtSymbolPath.hs b/apps/FixNtSymbolPath.hs
index c75291e..a44a840 100644
--- a/apps/FixNtSymbolPath.hs
+++ b/apps/FixNtSymbolPath.hs
@@ -6,9 +6,9 @@
module Main (main) where
-import Control.Monad (unless)
+import Control.Monad (unless)
import System.Directory (createDirectoryIfMissing, getCurrentDirectory)
-import System.FilePath (combine)
+import System.FilePath (combine)
import qualified Environment
@@ -32,16 +32,16 @@ getPdbsDirectoryPath = do
fixNtSymbolPath :: IO ()
fixNtSymbolPath = do
- let env = Environment.CurrentUserEnvironment
- val <- Environment.queryFromRegistry env ntSymbolPath
- let presentPaths = Environment.splitPaths val
+ let env = Environment.CurrentUser
+ val <- Environment.query env ntSymbolPath
+ let presentPaths = Environment.pathSplit val
remoteSymbolsPath <- getRemoteSymbolsDirectoryPath
pdbsPath <- getPdbsDirectoryPath
let requiredPaths = [pdbsPath, remoteSymbolsPath]
let missingPaths = filter (`notElem` presentPaths) requiredPaths
unless (null missingPaths) $ do
- let newval = Environment.joinPaths $ presentPaths ++ missingPaths
- Environment.saveToRegistry env ntSymbolPath newval
+ let newval = Environment.pathJoin $ presentPaths ++ missingPaths
+ Environment.engrave env ntSymbolPath newval
where
ntSymbolPath = "_NT_SYMBOL_PATH"
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
diff --git a/apps/RemovePath.hs b/apps/RemovePath.hs
index d85a7f4..e04a67b 100644
--- a/apps/RemovePath.hs
+++ b/apps/RemovePath.hs
@@ -42,14 +42,14 @@ main = execParser parser >>= removePath
removePath :: Options -> IO ()
removePath options = do
let varName = name options
- userVal <- Environment.queryFromRegistry Environment.CurrentUserEnvironment varName
- let userValParts = Environment.splitPaths userVal
+ userVal <- Environment.query Environment.CurrentUser varName
+ let userValParts = Environment.pathSplit userVal
let newUserValParts = filter (flip notElem $ paths options) userValParts
when (length userValParts /= length newUserValParts) $ do
- Environment.saveToRegistryWithPrompt Environment.CurrentUserEnvironment varName $ Environment.joinPaths newUserValParts
+ Environment.engraveWithPrompt Environment.CurrentUser varName $ Environment.pathJoin newUserValParts
when (global options) $ do
- globalVal <- Environment.queryFromRegistry Environment.AllUsersEnvironment varName
- let globalValParts = Environment.splitPaths globalVal
+ globalVal <- Environment.query Environment.AllUsers varName
+ let globalValParts = Environment.pathSplit globalVal
let newGlobalValParts = filter (flip notElem $ paths options) globalValParts
when (length globalValParts /= length newGlobalValParts) $ do
- Environment.saveToRegistryWithPrompt Environment.AllUsersEnvironment varName $ Environment.joinPaths newGlobalValParts
+ Environment.engraveWithPrompt Environment.AllUsers varName $ Environment.pathJoin newGlobalValParts
diff --git a/apps/SetEnv.hs b/apps/SetEnv.hs
index d3439ae..fad7526 100644
--- a/apps/SetEnv.hs
+++ b/apps/SetEnv.hs
@@ -39,7 +39,7 @@ main = execParser parser >>= setEnv
fullDesc <> progDesc "Set environment variables"
setEnv :: Options -> IO ()
-setEnv options = Environment.saveToRegistryWithPrompt env (name options) (value options)
+setEnv options = Environment.engraveWithPrompt env (name options) (value options)
where
- env | global options = Environment.AllUsersEnvironment
- | otherwise = Environment.CurrentUserEnvironment
+ env | global options = Environment.AllUsers
+ | otherwise = Environment.CurrentUser
diff --git a/apps/UnsetEnv.hs b/apps/UnsetEnv.hs
index bf7ad93..6fa2f2c 100644
--- a/apps/UnsetEnv.hs
+++ b/apps/UnsetEnv.hs
@@ -34,7 +34,7 @@ main = execParser parser >>= unsetEnv
fullDesc <> progDesc "Unset environment variables"
unsetEnv :: Options -> IO ()
-unsetEnv options = Environment.wipeFromRegistryWithPrompt env $ name options
+unsetEnv options = Environment.wipeWithPrompt env $ name options
where
- env | global options = Environment.AllUsersEnvironment
- | otherwise = Environment.CurrentUserEnvironment
+ env | global options = Environment.AllUsers
+ | otherwise = Environment.CurrentUser