| Copyright | (c) Eric Mertens 2016-2020 |
|---|---|
| License | ISC |
| Maintainer | emertens@gmail.com |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Client.Commands.Types
Description
Synopsis
- data CommandResult
- type ClientCommand a = ClientState -> a -> IO CommandResult
- type WindowCommand a = Focus -> ClientCommand a
- type NetworkCommand a = NetworkState -> ClientCommand a
- type MaybeChatCommand a = Maybe Identifier -> NetworkCommand a
- type ChannelCommand a = Identifier -> NetworkCommand a
- data CommandImpl a
- = ClientCommand (ClientCommand a) (Bool -> ClientCommand String)
- | WindowCommand (WindowCommand a) (Bool -> WindowCommand String)
- | NetworkCommand (NetworkCommand a) (Bool -> NetworkCommand String)
- | MaybeChatCommand (MaybeChatCommand a) (Bool -> MaybeChatCommand String)
- | ChatCommand (ChannelCommand a) (Bool -> ChannelCommand String)
- | ChannelCommand (ChannelCommand a) (Bool -> ChannelCommand String)
- data ArgsContext = ArgsContext {}
- makeArgsContext :: ClientState -> ArgsContext
- data Command = forall a.Command {}
- data CommandSection = CommandSection {
- cmdSectionName :: Text
- cmdSectionCmds :: [Command]
- commandSuccess :: Monad m => ClientState -> m CommandResult
- commandSuccessUpdateCS :: NetworkState -> ClientState -> IO CommandResult
- commandFailure :: Monad m => ClientState -> m CommandResult
- commandFailureMsg :: Text -> ClientState -> IO CommandResult
Documentation
data CommandResult Source #
Possible results of running a command
Constructors
| CommandSuccess ClientState | Continue running the client, consume input if command was from input |
| CommandFailure ClientState | Continue running the client, report an error |
| CommandQuit ClientState | Client should close |
type ClientCommand a Source #
Arguments
| = ClientState | |
| -> a | arguments |
| -> IO CommandResult |
Type of commands that always work
type WindowCommand a = Focus -> ClientCommand a Source #
Type of commands that operate on a window
type NetworkCommand a Source #
Arguments
| = NetworkState | current network |
| -> ClientCommand a |
Type of commands that require an active network to be focused
type MaybeChatCommand a Source #
Arguments
| = Maybe Identifier | focused channel |
| -> NetworkCommand a |
Type of commands that require an active network to be focused and maybe a chat window.
type ChannelCommand a Source #
Arguments
| = Identifier | focused channel |
| -> NetworkCommand a |
Type of commands that require an active channel to be focused
data CommandImpl a Source #
Pair of implementations for executing a command and tab completing one. The tab-completion logic is extended with a Bool indicating that tab completion should be reversed
Constructors
| ClientCommand (ClientCommand a) (Bool -> ClientCommand String) | no requirements |
| WindowCommand (WindowCommand a) (Bool -> WindowCommand String) | operates on a window |
| NetworkCommand (NetworkCommand a) (Bool -> NetworkCommand String) | requires an active network |
| MaybeChatCommand (MaybeChatCommand a) (Bool -> MaybeChatCommand String) | requires an active network and maybe a chat window |
| ChatCommand (ChannelCommand a) (Bool -> ChannelCommand String) | requires an active chat window |
| ChannelCommand (ChannelCommand a) (Bool -> ChannelCommand String) | requires an active channel window |
data ArgsContext Source #
Data available to the arguments parser at the time of parsing.
Constructors
| ArgsContext | |
Fields | |
A command is a list of aliases, an argument specification, implementation, and documentation. The arguments and implementation must match so that the parsed arguments will match what the implementation expects.
Constructors
| forall a. Command | |
Fields
| |
data CommandSection Source #
A command section is a logical grouping of commands. This allows for showing more structure in the help menu system.
Constructors
| CommandSection | |
Fields
| |
commandSuccess :: Monad m => ClientState -> m CommandResult Source #
Consider the text entry successful and resume the client
commandSuccessUpdateCS :: NetworkState -> ClientState -> IO CommandResult Source #
Consider the text entry successful, and resume the client with a particular network updated.
commandFailure :: Monad m => ClientState -> m CommandResult Source #
Consider the text entry a failure and resume the client
commandFailureMsg :: Text -> ClientState -> IO CommandResult Source #
Command failure with an error message printed to client window