structured-cli 2.2.0.0 → 2.2.1.0
raw patch · 2 files changed
+20/−6 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ System.Console.StructuredCLI: isFailed :: Monad m => SearchResult m -> Bool
- System.Console.StructuredCLI: (>+) :: (Monad m) => CommandsT m () -> CommandsT m () -> CommandsT m ()
+ System.Console.StructuredCLI: (>+) :: Monad m => CommandsT m () -> CommandsT m () -> CommandsT m ()
- System.Console.StructuredCLI: SyntaxError :: String -> CLIException
+ System.Console.StructuredCLI: SyntaxError :: String -> String -> CLIException
- System.Console.StructuredCLI: command :: (Monad m) => String -> String -> m Action -> CommandsT m ()
+ System.Console.StructuredCLI: command :: Monad m => String -> String -> m Action -> CommandsT m ()
- System.Console.StructuredCLI: command' :: (Monad m) => String -> String -> m Bool -> m Action -> CommandsT m ()
+ System.Console.StructuredCLI: command' :: Monad m => String -> String -> m Bool -> m Action -> CommandsT m ()
- System.Console.StructuredCLI: custom :: (Monad m) => String -> String -> Parser m -> m Bool -> Handler m -> CommandsT m ()
+ System.Console.StructuredCLI: custom :: Monad m => String -> String -> Parser m -> m Bool -> Handler m -> CommandsT m ()
- System.Console.StructuredCLI: exit :: (Monad m) => m Action
+ System.Console.StructuredCLI: exit :: Monad m => m Action
- System.Console.StructuredCLI: isCompleted :: (Monad m) => SearchResult m -> Bool
+ System.Console.StructuredCLI: isCompleted :: Monad m => SearchResult m -> Bool
- System.Console.StructuredCLI: isIncomplete :: (Monad m) => SearchResult m -> Bool
+ System.Console.StructuredCLI: isIncomplete :: Monad m => SearchResult m -> Bool
- System.Console.StructuredCLI: isNoResult :: (Monad m) => SearchResult m -> Bool
+ System.Console.StructuredCLI: isNoResult :: Monad m => SearchResult m -> Bool
- System.Console.StructuredCLI: labelParser :: (Monad m) => Node m -> String -> m ParseResult
+ System.Console.StructuredCLI: labelParser :: Monad m => Node m -> String -> m ParseResult
- System.Console.StructuredCLI: newLevel :: (Monad m) => m Action
+ System.Console.StructuredCLI: newLevel :: Monad m => m Action
- System.Console.StructuredCLI: noAction :: (Monad m) => m Action
+ System.Console.StructuredCLI: noAction :: Monad m => m Action
- System.Console.StructuredCLI: param :: (Monad m) => String -> String -> Validator m -> Handler m -> CommandsT m ()
+ System.Console.StructuredCLI: param :: Monad m => String -> String -> Validator m -> Handler m -> CommandsT m ()
- System.Console.StructuredCLI: param' :: (Monad m) => String -> String -> Validator m -> m Bool -> Handler m -> CommandsT m ()
+ System.Console.StructuredCLI: param' :: Monad m => String -> String -> Validator m -> m Bool -> Handler m -> CommandsT m ()
- System.Console.StructuredCLI: runCLI :: (MonadException m) => String -> Settings m -> CommandsT m a -> m (Either CLIException a)
+ System.Console.StructuredCLI: runCLI :: MonadException m => String -> Settings m -> CommandsT m a -> m (Either CLIException a)
- System.Console.StructuredCLI: top :: (Monad m) => m Action
+ System.Console.StructuredCLI: top :: Monad m => m Action
Files
src/System/Console/StructuredCLI.hs view
@@ -93,6 +93,7 @@ isCompleted, isIncomplete, isNoResult,+ isFailed, labelParser, newLevel, noAction,@@ -215,7 +216,7 @@ data CLIException = Exit | InternalError String- | SyntaxError String+ | SyntaxError String String | UndecisiveInput String [String] | HelpRequested [(String, String)] | InvalidOperation String@@ -306,6 +307,10 @@ isNoResult NoResult = True isNoResult _ = False +isFailed :: (Monad m) => SearchResult m -> Bool+isFailed Failed{..} = True+isFailed _ = False+ -- | the CommandsT "nest" operation. It adds a new deeper CLI level to the command on the left -- side with the commands on the right side, for example: -- @@@ -489,8 +494,8 @@ loop defExceptionHandler :: (MonadIO m) => CLIException -> m (Either CLIException ())-defExceptionHandler (SyntaxError str) = do- fmap Right . liftIO . putStrLn $ "SyntaxError at or around " ++ str ++ "\n"+defExceptionHandler (SyntaxError str msg) = do+ fmap Right . liftIO . putStrLn $ "SyntaxError at or around " ++ str ++ ": " ++ msg ++ "\n" defExceptionHandler (HelpRequested hints) = fmap Right . liftIO $ do mapM_ display $ hints@@ -568,7 +573,16 @@ debugM $ "help requested: " ++ show hints throwError . HelpRequested $ hints else- throwError . SyntaxError $ input+ case filter isFailed result of+ Failed{..}:_ ->+ throwError . SyntaxError input $ failedMsg+ _ ->+ case filter isIncomplete result of+ Incomplete{..}:_ ->+ throwError . SyntaxError input . snd . head $ incompleteHints+ _ ->+ throwError . SyntaxError input $ ""+ where checkForHelp ('?':_) = True checkForHelp _ = False getHelp acc Failed{..} = (getLabel failedNode, failedMsg):acc
structured-cli.cabal view
@@ -1,5 +1,5 @@ name: structured-cli-version: 2.2.0.0+version: 2.2.1.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://gitlab.com/codemonkeylabs/structured-cli#readme@@ -14,7 +14,7 @@ cabal-version: >=1.10 flag debug- description: Enable debug messages + description: Enable debug messages default: False library