diff options
Diffstat (limited to '')
-rw-r--r-- | apps/AddPath.hs | 21 | ||||
-rw-r--r-- | apps/FixNtSymbolPath.hs | 17 | ||||
-rw-r--r-- | apps/ListPath.hs | 9 | ||||
-rw-r--r-- | apps/RemovePath.hs | 21 | ||||
-rw-r--r-- | apps/SetEnv.hs | 15 | ||||
-rw-r--r-- | apps/UnsetEnv.hs | 13 | ||||
-rw-r--r-- | apps/Utils.hs | 2 | ||||
-rw-r--r-- | src/Windows/Environment.hs (renamed from src/Environment.hs) | 6 | ||||
-rw-r--r-- | src/Windows/Registry.hs (renamed from src/Registry.hs) | 2 | ||||
-rw-r--r-- | src/Windows/Utils.hs (renamed from src/WindowsUtils.hs) | 2 | ||||
-rw-r--r-- | windows-env.cabal | 3 |
11 files changed, 53 insertions, 58 deletions
diff --git a/apps/AddPath.hs b/apps/AddPath.hs index 6103d1d..db0dcc2 100644 --- a/apps/AddPath.hs +++ b/apps/AddPath.hs @@ -11,17 +11,16 @@ import Data.List (union) import Data.Maybe (fromMaybe) import Text.Printf (printf) -import Options.Applicative - -import qualified Environment +import Options.Applicative +import qualified Windows.Environment as Env import qualified Utils data Options = Options - { optName :: Environment.VarName + { optName :: Env.VarName , optYes :: Bool , optGlobal :: Bool - , optPaths :: [Environment.VarValue] + , optPaths :: [Env.VarValue] } deriving (Eq, Show) options :: Parser Options @@ -52,21 +51,21 @@ main = execParser parser >>= addPath addPath :: Options -> IO () addPath options = do - oldValue <- Environment.query profile varName - let oldPaths = Environment.pathSplit $ fromMaybe "" oldValue + oldValue <- Env.query profile varName + let oldPaths = Env.pathSplit $ fromMaybe "" oldValue let newPaths = union oldPaths pathsToAdd when (length oldPaths /= length newPaths) $ do - let newValue = Environment.pathJoin newPaths + let newValue = Env.pathJoin newPaths let promptBanner = Utils.engraveBanner profile varName oldValue newValue - void $ prompt promptBanner $ Environment.engrave profile varName newValue + void $ prompt promptBanner $ Env.engrave profile varName newValue where varName = optName options pathsToAdd = optPaths options forAllUsers = optGlobal options profile = if forAllUsers - then Environment.AllUsers - else Environment.CurrentUser + then Env.AllUsers + else Env.CurrentUser skipPrompt = optYes options prompt = if skipPrompt diff --git a/apps/FixNtSymbolPath.hs b/apps/FixNtSymbolPath.hs index 3788381..8c999a8 100644 --- a/apps/FixNtSymbolPath.hs +++ b/apps/FixNtSymbolPath.hs @@ -12,9 +12,8 @@ import Data.Maybe (fromMaybe) import System.Directory (createDirectoryIfMissing, getCurrentDirectory) import System.FilePath (combine) -import Options.Applicative - -import qualified Environment +import Options.Applicative +import qualified Windows.Environment as Env import qualified Utils @@ -66,15 +65,15 @@ getLocalDirs = do fixNtSymbolPath :: Options -> IO () fixNtSymbolPath options = do - oldValue <- Environment.query profile varName - let oldPaths = Environment.pathSplit $ fromMaybe "" oldValue + oldValue <- Env.query profile varName + let oldPaths = Env.pathSplit $ fromMaybe "" oldValue localDirs <- getLocalDirs let remoteDirs = toRemoteDirs localDirs let newPaths = union oldPaths $ dirPaths remoteDirs when (length oldPaths /= length newPaths) $ do - let newValue = Environment.pathJoin newPaths + let newValue = Env.pathJoin newPaths let promptBanner = Utils.engraveBanner profile varName oldValue newValue - confirmed <- prompt promptBanner $ Environment.engrave profile varName newValue + confirmed <- prompt promptBanner $ Env.engrave profile varName newValue when confirmed $ createDirs localDirs where @@ -82,8 +81,8 @@ fixNtSymbolPath options = do forAllUsers = optGlobal options profile = if forAllUsers - then Environment.AllUsers - else Environment.CurrentUser + then Env.AllUsers + else Env.CurrentUser skipPrompt = optYes options prompt = if skipPrompt diff --git a/apps/ListPath.hs b/apps/ListPath.hs index ace3ede..f33983d 100644 --- a/apps/ListPath.hs +++ b/apps/ListPath.hs @@ -11,12 +11,11 @@ import Data.Maybe (fromMaybe) import System.Directory (doesDirectoryExist) import System.Environment (lookupEnv) -import Options.Applicative - -import qualified Environment +import Options.Applicative +import qualified Windows.Environment as Env data Options = Options - { optName :: Environment.VarName + { optName :: Env.VarName } deriving (Eq, Show) options :: Parser Options @@ -35,7 +34,7 @@ main = execParser parser >>= listPath listPath :: Options -> IO () listPath options = do oldValue <- getEnv varName - let oldPaths = Environment.pathSplit oldValue + let oldPaths = Env.pathSplit oldValue mapM_ printPath oldPaths where varName = optName options diff --git a/apps/RemovePath.hs b/apps/RemovePath.hs index a594ecd..ecc56c0 100644 --- a/apps/RemovePath.hs +++ b/apps/RemovePath.hs @@ -10,17 +10,16 @@ import Control.Monad (void, when) import Data.List ((\\)) import Data.Maybe (fromJust, isJust) -import Options.Applicative - -import qualified Environment +import Options.Applicative +import qualified Windows.Environment as Env import qualified Utils data Options = Options - { optName :: Environment.VarName + { optName :: Env.VarName , optYes :: Bool , optGlobal :: Bool - , optPaths :: [Environment.VarValue] + , optPaths :: [Env.VarValue] } deriving (Eq, Show) options = Options @@ -50,9 +49,9 @@ main = execParser parser >>= removePath removePath :: Options -> IO () removePath options = do - removePathFrom Environment.CurrentUser + removePathFrom Env.CurrentUser when forAllUsers $ do - removePathFrom Environment.AllUsers + removePathFrom Env.AllUsers where varName = optName options pathsToRemove = optPaths options @@ -60,14 +59,14 @@ removePath options = do forAllUsers = optGlobal options removePathFrom profile = do - oldValue <- Environment.query profile varName + oldValue <- Env.query profile varName when (isJust oldValue) $ do - let oldPaths = Environment.pathSplit $ fromJust oldValue + let oldPaths = Env.pathSplit $ fromJust oldValue let newPaths = oldPaths \\ pathsToRemove when (length oldPaths /= length newPaths) $ do - let newValue = Environment.pathJoin newPaths + let newValue = Env.pathJoin newPaths let promptBanner = Utils.engraveBanner profile varName oldValue newValue - void $ prompt promptBanner $ Environment.engrave profile varName newValue + void $ prompt promptBanner $ Env.engrave profile varName newValue skipPrompt = optYes options prompt = if skipPrompt diff --git a/apps/SetEnv.hs b/apps/SetEnv.hs index 0b95176..a48fbe6 100644 --- a/apps/SetEnv.hs +++ b/apps/SetEnv.hs @@ -8,17 +8,16 @@ module Main (main) where import Control.Monad (void) -import Options.Applicative hiding (value) - -import qualified Environment +import Options.Applicative +import qualified Windows.Environment as Env import qualified Utils data Options = Options { optYes :: Bool , optGlobal :: Bool - , optName :: Environment.VarName - , optValue :: Environment.VarValue + , optName :: Env.VarName + , optValue :: Env.VarValue } deriving (Eq, Show) options :: Parser Options @@ -48,7 +47,7 @@ main = execParser parser >>= setEnv fullDesc <> progDesc "Set environment variable" setEnv :: Options -> IO () -setEnv options = void $ prompt confirmationBanner $ Environment.engrave profile varName varValue +setEnv options = void $ prompt confirmationBanner $ Env.engrave profile varName varValue where confirmationBanner = Utils.engraveBanner profile varName Nothing varValue @@ -57,8 +56,8 @@ setEnv options = void $ prompt confirmationBanner $ Environment.engrave profile forAllUsers = optGlobal options profile = if forAllUsers - then Environment.AllUsers - else Environment.CurrentUser + then Env.AllUsers + else Env.CurrentUser skipPrompt = optYes options prompt = if skipPrompt diff --git a/apps/UnsetEnv.hs b/apps/UnsetEnv.hs index b0ed96a..88101d9 100644 --- a/apps/UnsetEnv.hs +++ b/apps/UnsetEnv.hs @@ -8,16 +8,15 @@ module Main (main) where import Control.Monad (void) -import Options.Applicative - -import qualified Environment +import Options.Applicative +import qualified Windows.Environment as Env import qualified Utils data Options = Options { optYes :: Bool , optGlobal :: Bool - , optName :: Environment.VarName + , optName :: Env.VarName } deriving (Eq, Show) options :: Parser Options @@ -43,7 +42,7 @@ main = execParser parser >>= unsetEnv fullDesc <> progDesc "Unset environment variable" unsetEnv :: Options -> IO () -unsetEnv options = void $ prompt confirmationBanner $ Environment.wipe profile varName +unsetEnv options = void $ prompt confirmationBanner $ Env.wipe profile varName where confirmationBanner = Utils.wipeBanner profile varName @@ -51,8 +50,8 @@ unsetEnv options = void $ prompt confirmationBanner $ Environment.wipe profile v forAllUsers = optGlobal options profile = if forAllUsers - then Environment.AllUsers - else Environment.CurrentUser + then Env.AllUsers + else Env.CurrentUser skipPrompt = optYes options prompt = if skipPrompt diff --git a/apps/Utils.hs b/apps/Utils.hs index 28309d4..e34950f 100644 --- a/apps/Utils.hs +++ b/apps/Utils.hs @@ -18,7 +18,7 @@ import Data.Char (toLower) import System.IO (hFlush, stdout) import Text.Printf (printf) -import Environment (Profile, profileKeyPath, VarName, VarValue) +import Windows.Environment (Profile, profileKeyPath, VarName, VarValue) prompt :: String -> IO String prompt banner = do diff --git a/src/Environment.hs b/src/Windows/Environment.hs index f370de4..2bea481 100644 --- a/src/Environment.hs +++ b/src/Windows/Environment.hs @@ -4,7 +4,7 @@ - See LICENSE.txt for details. -} -module Environment +module Windows.Environment ( Profile(..) , profileKeyPath @@ -22,8 +22,8 @@ import Data.List (intercalate) import Data.List.Split (splitOn) import System.IO.Error (catchIOError, isDoesNotExistError) -import qualified Registry -import WindowsUtils (notifyEnvironmentUpdate) +import qualified Windows.Registry as Registry +import Windows.Utils (notifyEnvironmentUpdate) data Profile = CurrentUser | AllUsers diff --git a/src/Registry.hs b/src/Windows/Registry.hs index 48d69f0..528027f 100644 --- a/src/Registry.hs +++ b/src/Windows/Registry.hs @@ -4,7 +4,7 @@ - See LICENSE.txt for details. -} -module Registry +module Windows.Registry ( KeyPath , keyPathFromString , keyPathJoin diff --git a/src/WindowsUtils.hs b/src/Windows/Utils.hs index 6fa1f0e..aad241f 100644 --- a/src/WindowsUtils.hs +++ b/src/Windows/Utils.hs @@ -4,7 +4,7 @@ - See LICENSE.txt for details. -} -module WindowsUtils +module Windows.Utils ( notifyEnvironmentUpdate ) where diff --git a/windows-env.cabal b/windows-env.cabal index aa0190e..d34684f 100644 --- a/windows-env.cabal +++ b/windows-env.cabal @@ -15,7 +15,8 @@ cabal-version: >=1.10 library hs-source-dirs: src - exposed-modules: Environment, Registry, WindowsUtils + exposed-modules: Windows.Environment + other-modules: Windows.Registry, Windows.Utils ghc-options: -Wall -Werror build-depends: base, split, Win32 default-language: Haskell2010 |