structured-cli 0.9.2.0 → 0.9.3.0
raw patch · 3 files changed
+10/−8 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ System.Console.StructuredCLI: State :: [Node m] -> [String] -> State m
+ System.Console.StructuredCLI: [labels] :: State m -> [String]
+ System.Console.StructuredCLI: [nodes] :: State m -> [Node m]
+ System.Console.StructuredCLI: data State m
+ System.Console.StructuredCLI: type Action m = CState m Int
Files
- example/Main.hs +6/−6
- src/System/Console/StructuredCLI.hs +3/−1
- structured-cli.cabal +1/−1
example/Main.hs view
@@ -10,10 +10,10 @@ import System.Console.StructuredCLI import Text.Read (readMaybe) -data State = State { bars :: Int,- bazs :: Int }+data AppState = AppState { bars :: Int,+ bazs :: Int } -type StateM = StateT State IO+type StateM = StateT AppState IO root :: CommandsT StateM () root = do@@ -42,7 +42,7 @@ n <- lift $ modify incBaz >> gets bazs liftIO . putStrLn $ "You have bazzed " ++ show n ++ " times" return 0- where incBaz s@State{..} = s { bazs = bazs + 1 }+ where incBaz s@AppState{..} = s { bazs = bazs + 1 } frob :: CommandsT StateM () frob = command "frob" (Just "frob this level") $ Just $ do@@ -61,13 +61,13 @@ where complain = do return $ failure name accept x remaining n = do- modify $ \s@State{..} -> s { bars = n }+ modify $ \s@AppState{..} -> s { bars = n } return $ Done x remaining failure :: String -> ParseResult failure name = Fail name $ Just "<number of times to bar>" main :: IO ()-main = evalStateT (runCLI "some CLI" (Just settings) root) $ State 0 0+main = evalStateT (runCLI "some CLI" (Just settings) root) $ AppState 0 0 where settings = def { banner = "Some CLI Application\nTab completion is your friend!", history = Just ".someCLI.history" }
src/System/Console/StructuredCLI.hs view
@@ -58,11 +58,13 @@ -- >>> Hello CLI world > exit -- -- A good way to get you started is to grab the example code available under <https://github.com/erickg/structured-cli/blob/master/example/Main.hs example/Main.hs> and modify it to suit your needs.+ Action, Commands, CommandsT(..), Parser, ParseResult(..), Settings(..),+ State(..), (>+), command, exit,@@ -256,7 +258,7 @@ throw Exit else lift $ modify $ \state -> state { nodes = nodes0, -- parse failed or no action- labels = labels0 } -- restore nodes to previous state+ labels = labels0 } -- restore nodes to previous state Just _ -> do Node{..} <- lift getCurrentCommand case action of
structured-cli.cabal view
@@ -1,5 +1,5 @@ name: structured-cli-version: 0.9.2.0+version: 0.9.3.0 synopsis: Application library for building interactive console CLIs description: This module provides the tools to build a complete "structured" CLI application, similar to those found in systems like Cisco IOS or console configuration utilities etc. It aims to be easy for implementors to use. homepage: https://github.com/erickg/structured-cli#readme