@@ -26,6 +26,7 @@ data Arg = Help
2626 | OutputPath String
2727 | TableUpperBound String
2828 | UpdateConfig
29+ | VtyConfigPath String
2930 deriving (Eq, Show)
3031
3132options :: Config -> [OptDescr Arg]
@@ -40,12 +41,16 @@ options config =
4041 fromMaybe "<none>" (configOutputPath config) <> ")")
4142 , Option "u" ["update-config"] (NoArg UpdateConfig)
4243 "Create or update the Vty configuration file to use the new map (default: no)"
44+ , Option "c" ["config-path"] (ReqArg VtyConfigPath "PATH")
45+ ("Update the specified Vty configuration file path when -u is set (default: " <>
46+ configPath config <> ")")
4347 ]
4448
4549data Config =
4650 Config { configOutputPath :: Maybe FilePath
4751 , configBound :: Char
4852 , configUpdate :: Bool
53+ , configPath :: FilePath
4954 }
5055 deriving (Show)
5156
@@ -54,6 +59,7 @@ mkDefaultConfig = do
5459 Config <$> terminalWidthTablePath
5560 <*> pure defaultUnicodeTableUpperBound
5661 <*> pure False
62+ <*> vtyConfigPath
5763
5864usage :: IO ()
5965usage = do
@@ -74,6 +80,8 @@ updateConfigFromArg Help c =
7480 c
7581updateConfigFromArg UpdateConfig c =
7682 c { configUpdate = True }
83+updateConfigFromArg (VtyConfigPath p) c =
84+ c { configPath = p }
7785updateConfigFromArg (TableUpperBound s) c =
7886 case readMaybe s of
7987 Nothing -> error $ "Invalid table upper bound: " <> show s
@@ -113,20 +121,19 @@ main = do
113121
114122 when (configUpdate config) $ do
115123 Just tName <- currentTerminalName
116− configPath <- vtyConfigPath
117124
118− result <- E.try $ addConfigWidthMap configPath tName outputPath
125+ result <- E.try $ addConfigWidthMap (configPath config) tName outputPath
119126
120127 putStrLn ""
121128 case result of
122129 Left (e::E.SomeException) -> do
123− putStrLn $ "Error updating Vty configuration at " <> configPath <> ": " <> show e
130+ putStrLn $ "Error updating Vty configuration at " <> (configPath config) <> ": " <> show e
124131 exitFailure
125132 Right ConfigurationCreated -> do
126− putStrLn $ "Configuration file created: " <> configPath
133+ putStrLn $ "Configuration file created: " <> (configPath config)
127134 Right ConfigurationModified -> do
128− putStrLn $ "Configuration file updated: " <> configPath
135+ putStrLn $ "Configuration file updated: " <> (configPath config)
129136 Right (ConfigurationConflict other) -> do
130137 putStrLn $ "Configuration file not updated: uses a different map for terminal type " <> tName <> ": " <> other
131138 Right ConfigurationRedundant -> do
132− putStrLn $ "Configuration file not updated: configuration already contains map " <> outputPath <> " for TERM=" <> tName
139+ putStrLn $ "Configuration file not updated: configuration " <> (configPath config) <> " already contains map " <> outputPath <> " for TERM=" <> tName