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 NetworkCommand a = NetworkState -> ClientCommand a
- type ChannelCommand a = Identifier -> NetworkCommand a
- data CommandImpl a
- = ClientCommand (ClientCommand a) (Bool -> ClientCommand String)
- | NetworkCommand (NetworkCommand a) (Bool -> NetworkCommand String)
- | ChatCommand (ChannelCommand a) (Bool -> ChannelCommand String)
- | ChannelCommand (ChannelCommand a) (Bool -> ChannelCommand String)
- 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 NetworkCommand a Source #
Arguments
= NetworkState | current network |
-> ClientCommand a |
Type of commands that require an active network to be focused
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 |
NetworkCommand (NetworkCommand a) (Bool -> NetworkCommand String) | requires an active network |
ChatCommand (ChannelCommand a) (Bool -> ChannelCommand String) | requires an active chat window |
ChannelCommand (ChannelCommand a) (Bool -> ChannelCommand String) | requires an active channel window |
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