ui-command 0.5.2 → 0.5.3
raw patch · 3 files changed
+16/−7 lines, 3 files
Files
- UI/Command/Doc.hs +6/−1
- UI/Command/Main.hs +9/−5
- ui-command.cabal +1/−1
UI/Command/Doc.hs view
@@ -1,6 +1,6 @@ module UI.Command.Doc ( helpCmd, manCmd,- help, man+ helpErr, help, man )where import Data.Default@@ -9,6 +9,7 @@ import System.Locale (defaultTimeLocale) import Data.Time.Format (formatTime) import Data.Time.Clock (getCurrentTime)+import System.IO (hPutStr, stderr) import Text.Printf (printf) @@ -35,6 +36,10 @@ cmdName = "help", cmdShortDesc = "Display help for a specific cmdcommand" }++helpErr app = do+ args <- appArgs+ liftIO $ mapM_ (hPutStr stderr) $ longHelp app args --help :: (Default opts, Default config) => Application opts config -> [String] -> IO () -- help :: (Default opts, Default config) => Application opts config -> App config ()
UI/Command/Main.hs view
@@ -22,12 +22,16 @@ -- -- -initApp :: (Default opts, Default config) => Application opts config -> [String] -> IO (AppContext config)+initApp :: (Default opts, Default config)+ => Application opts config -> [String]+ -> IO (AppContext config) initApp app args = do (config, args) <- processArgs app args return $ AppContext config args -processArgs :: (Default opts, Default config) => Application opts config -> [String] -> IO (config, [String])+processArgs :: (Default opts, Default config)+ => Application opts config -> [String]+ -> IO (config, [String]) processArgs app args = do case getOpt RequireOrder (appOptions app) args of (opts, args' , [] ) -> do@@ -86,13 +90,13 @@ handleCommand app (command:args) | command == "help" = showHelp app args | command == "man" = showMan- | otherwise = (initApp app args) >>= loop1+ | otherwise = initApp app args >>= loop1 where- showMan = (initApp app args) >>= loopMan+ showMan = initApp app args >>= loopMan loopMan st = runReaderT (man app) st loop1 st = runReaderT run st -- docCmds :: (Default config1) => [Command config1] -- docCmds = [helpCmd{cmdHandler = help app}, manCmd{cmdHandler = man app}] run = act $ filter (\x -> cmdName x == command) (appCmds app)- act [] = help app+ act [] = helpErr app act (s:_) = cmdHandler s
ui-command.cabal view
@@ -1,5 +1,5 @@ Name: ui-command-Version: 0.5.2+Version: 0.5.3 License: BSD3 License-file: LICENSE Author: Conrad Parker <conrad@metadecks.org>