aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/app
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2017-01-25 07:12:39 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2017-01-25 07:12:39 +0300
commit44a7cce93547336293745f3c750b046680195ffe (patch)
tree6c959ec6aff111c34f0fec92fa008a97c7bf4b1d /app
parentrename namespace 'Windows' to 'WindowsEnv' (diff)
downloadwindows-env-44a7cce93547336293745f3c750b046680195ffe.tar.gz
windows-env-44a7cce93547336293745f3c750b046680195ffe.zip
add a dummy module for re-exports
Diffstat (limited to '')
-rw-r--r--apps/AddPath.hs18
-rw-r--r--apps/ListPaths.hs16
-rw-r--r--apps/PromptMessage.hs14
-rw-r--r--apps/RemovePath.hs18
-rw-r--r--apps/SetEnv.hs12
-rw-r--r--apps/UnsetEnv.hs10
6 files changed, 44 insertions, 44 deletions
diff --git a/apps/AddPath.hs b/apps/AddPath.hs
index 0439873..73d86d0 100644
--- a/apps/AddPath.hs
+++ b/apps/AddPath.hs
@@ -14,16 +14,16 @@ import System.IO.Error (ioError, isDoesNotExistError)
import Options.Applicative
-import qualified WindowsEnv.Environment as Env
+import qualified WindowsEnv
import Prompt
import PromptMessage
data Options = Options
- { optName :: Env.VarName
+ { optName :: WindowsEnv.VarName
, optYes :: Bool
, optGlobal :: Bool
- , optPaths :: [Env.VarValue]
+ , optPaths :: [WindowsEnv.VarValue]
} deriving (Eq, Show)
optionParser :: Parser Options
@@ -61,8 +61,8 @@ addPath options = runExceptT doAddPath >>= either ioError return
forAllUsers = optGlobal options
profile
- | forAllUsers = Env.AllUsers
- | otherwise = Env.CurrentUser
+ | forAllUsers = WindowsEnv.AllUsers
+ | otherwise = WindowsEnv.CurrentUser
skipPrompt = optYes options
@@ -71,13 +71,13 @@ addPath options = runExceptT doAddPath >>= either ioError return
| otherwise = throwE e
doAddPath = do
- oldValue <- Env.query profile varName `catchE` emptyIfMissing
- let oldPaths = Env.pathSplit oldValue
+ oldValue <- WindowsEnv.query profile varName `catchE` emptyIfMissing
+ let oldPaths = WindowsEnv.pathSplit oldValue
let newPaths = oldPaths `union` pathsToAdd
when (length oldPaths /= length newPaths) $ do
- let newValue = Env.pathJoin newPaths
+ let newValue = WindowsEnv.pathJoin newPaths
let promptAnd = if skipPrompt
then withoutPrompt
else withPrompt $ oldNewMessage profile varName oldValue newValue
- let engrave = Env.engrave profile varName newValue
+ let engrave = WindowsEnv.engrave profile varName newValue
void $ promptAnd engrave
diff --git a/apps/ListPaths.hs b/apps/ListPaths.hs
index 543599e..666423f 100644
--- a/apps/ListPaths.hs
+++ b/apps/ListPaths.hs
@@ -17,21 +17,21 @@ import System.IO.Error (ioError)
import Options.Applicative
-import qualified WindowsEnv.Environment as Env
+import qualified WindowsEnv
data WhichPaths = All | ExistingOnly | MissingOnly
deriving (Eq, Show)
-shouldListPath :: WhichPaths -> Env.VarValue -> IO Bool
+shouldListPath :: WhichPaths -> WindowsEnv.VarValue -> IO Bool
shouldListPath All = return . const True
shouldListPath ExistingOnly = doesDirectoryExist
shouldListPath MissingOnly = fmap not . doesDirectoryExist
-data Source = Environment | Registry Env.Profile
+data Source = Environment | Registry WindowsEnv.Profile
deriving (Eq, Show)
data Options = Options
- { optName :: Env.VarName
+ { optName :: WindowsEnv.VarName
, optWhichPaths :: WhichPaths
, optSource :: Source
} deriving (Eq, Show)
@@ -52,9 +52,9 @@ optionParser = Options
<|> flag' MissingOnly (long "missing" <> short 'm'
<> help "List missing paths only")
optSourceDesc = pure Environment
- <|> flag' (Registry Env.CurrentUser) (long "user" <> short 'u'
+ <|> flag' (Registry WindowsEnv.CurrentUser) (long "user" <> short 'u'
<> help "List current user's paths only")
- <|> flag' (Registry Env.AllUsers) (long "global" <> short 'g'
+ <|> flag' (Registry WindowsEnv.AllUsers) (long "global" <> short 'g'
<> help "List global (all users') paths only")
main :: IO ()
@@ -73,12 +73,12 @@ listPaths options = runExceptT doListPaths >>= either ioError return
query = queryFrom source
queryFrom Environment = lift $ fromMaybe "" <$> lookupEnv varName
- queryFrom (Registry profile) = Env.query profile varName
+ queryFrom (Registry profile) = WindowsEnv.query profile varName
filterPaths = filterM $ shouldListPath whichPaths
doListPaths = do
- paths <- Env.pathSplit <$> query
+ paths <- WindowsEnv.pathSplit <$> query
lift $ do
pathsToPrint <- filterPaths paths
mapM_ putStrLn pathsToPrint
diff --git a/apps/PromptMessage.hs b/apps/PromptMessage.hs
index f5afd71..8dd3ef5 100644
--- a/apps/PromptMessage.hs
+++ b/apps/PromptMessage.hs
@@ -13,27 +13,27 @@ module PromptMessage
import Text.Printf (printf)
-import qualified WindowsEnv.Environment as Env
+import qualified WindowsEnv
-oldNewMessage :: Env.Profile -> Env.VarName -> Env.VarValue -> Env.VarValue -> String
+oldNewMessage :: WindowsEnv.Profile -> WindowsEnv.VarName -> WindowsEnv.VarValue -> WindowsEnv.VarValue -> String
oldNewMessage profile name oldValue newValue =
descrMsg ++ oldValueMsg ++ newValueMsg
where
- profileKey = Env.profileKeyPath profile
+ profileKey = WindowsEnv.profileKeyPath profile
descrMsg = printf "Saving variable '%s' to '%s'...\n" name (show profileKey)
oldValueMsg = printf "\tOld value: %s\n" oldValue
newValueMsg = printf "\tNew value: %s\n" newValue
-newMessage :: Env.Profile -> Env.VarName -> Env.VarValue -> String
+newMessage :: WindowsEnv.Profile -> WindowsEnv.VarName -> WindowsEnv.VarValue -> String
newMessage profile name newValue =
descrMsg ++ newValueMsg
where
- profileKey = Env.profileKeyPath profile
+ profileKey = WindowsEnv.profileKeyPath profile
descrMsg = printf "Saving variable '%s' to '%s'...\n" name (show profileKey)
newValueMsg = printf "\tNew value: %s\n" newValue
-wipeMessage :: Env.Profile -> Env.VarName -> String
+wipeMessage :: WindowsEnv.Profile -> WindowsEnv.VarName -> String
wipeMessage profile name =
printf "Deleting variable '%s' from '%s'...\n" name (show profileKey)
where
- profileKey = Env.profileKeyPath profile
+ profileKey = WindowsEnv.profileKeyPath profile
diff --git a/apps/RemovePath.hs b/apps/RemovePath.hs
index 446b837..7d0c104 100644
--- a/apps/RemovePath.hs
+++ b/apps/RemovePath.hs
@@ -14,16 +14,16 @@ import System.IO.Error (ioError, isDoesNotExistError)
import Options.Applicative
-import qualified WindowsEnv.Environment as Env
+import qualified WindowsEnv
import Prompt
import PromptMessage
data Options = Options
- { optName :: Env.VarName
+ { optName :: WindowsEnv.VarName
, optYes :: Bool
, optGlobal :: Bool
- , optPaths :: [Env.VarValue]
+ , optPaths :: [WindowsEnv.VarValue]
} deriving (Eq, Show)
optionParser :: Parser Options
@@ -68,18 +68,18 @@ removePath options = runExceptT doRemovePath >>= either ioError return
| otherwise = throwE e
doRemovePath = do
- removePathFrom Env.CurrentUser
+ removePathFrom WindowsEnv.CurrentUser
when forAllUsers $
- removePathFrom Env.AllUsers
+ removePathFrom WindowsEnv.AllUsers
removePathFrom profile = do
- oldValue <- Env.query profile varName `catchE` emptyIfMissing
- let oldPaths = Env.pathSplit oldValue
+ oldValue <- WindowsEnv.query profile varName `catchE` emptyIfMissing
+ let oldPaths = WindowsEnv.pathSplit oldValue
let newPaths = oldPaths \\ pathsToRemove
when (length oldPaths /= length newPaths) $ do
- let newValue = Env.pathJoin newPaths
+ let newValue = WindowsEnv.pathJoin newPaths
let promptAnd = if skipPrompt
then withoutPrompt
else withPrompt $ oldNewMessage profile varName oldValue newValue
- let engrave = Env.engrave profile varName newValue
+ let engrave = WindowsEnv.engrave profile varName newValue
void $ promptAnd engrave
diff --git a/apps/SetEnv.hs b/apps/SetEnv.hs
index 6cf5d29..87d7812 100644
--- a/apps/SetEnv.hs
+++ b/apps/SetEnv.hs
@@ -13,7 +13,7 @@ import System.IO.Error (ioError)
import Options.Applicative
-import qualified WindowsEnv.Environment as Env
+import qualified WindowsEnv
import Prompt
import PromptMessage
@@ -21,8 +21,8 @@ import PromptMessage
data Options = Options
{ optYes :: Bool
, optGlobal :: Bool
- , optName :: Env.VarName
- , optValue :: Env.VarValue
+ , optName :: WindowsEnv.VarName
+ , optValue :: WindowsEnv.VarValue
} deriving (Eq, Show)
optionParser :: Parser Options
@@ -59,14 +59,14 @@ setEnv options = runExceptT doSetEnv >>= either ioError return
forAllUsers = optGlobal options
profile
- | forAllUsers = Env.AllUsers
- | otherwise = Env.CurrentUser
+ | forAllUsers = WindowsEnv.AllUsers
+ | otherwise = WindowsEnv.CurrentUser
skipPrompt = optYes options
promptAnd
| skipPrompt = withoutPrompt
| otherwise = withPrompt $ newMessage profile varName varValue
- engrave = Env.engraveForce profile varName varValue
+ engrave = WindowsEnv.engraveForce profile varName varValue
doSetEnv = void $ promptAnd engrave
diff --git a/apps/UnsetEnv.hs b/apps/UnsetEnv.hs
index 65f0c91..f60503b 100644
--- a/apps/UnsetEnv.hs
+++ b/apps/UnsetEnv.hs
@@ -13,7 +13,7 @@ import System.IO.Error (ioError)
import Options.Applicative
-import qualified WindowsEnv.Environment as Env
+import qualified WindowsEnv
import Prompt
import PromptMessage
@@ -21,7 +21,7 @@ import PromptMessage
data Options = Options
{ optYes :: Bool
, optGlobal :: Bool
- , optName :: Env.VarName
+ , optName :: WindowsEnv.VarName
} deriving (Eq, Show)
optionParser :: Parser Options
@@ -53,14 +53,14 @@ unsetEnv options = runExceptT doUnsetEnv >>= either ioError return
forAllUsers = optGlobal options
profile
- | forAllUsers = Env.AllUsers
- | otherwise = Env.CurrentUser
+ | forAllUsers = WindowsEnv.AllUsers
+ | otherwise = WindowsEnv.CurrentUser
skipPrompt = optYes options
promptAnd
| skipPrompt = withoutPrompt
| otherwise = withPrompt $ wipeMessage profile varName
- wipe = Env.wipe profile varName
+ wipe = WindowsEnv.wipe profile varName
doUnsetEnv = void $ promptAnd wipe