pub struct ClapCmd<State = (), History = MemHistory>where
State: Clone,
History: History,{
pub output: String,
pub info: String,
pub warn: String,
pub error: String,
pub success: String,
pub async_output: Arc<Mutex<String>>,
/* private fields */
}
Expand description
An interactive CLI interface, holding state and responsible for acquiring user input and assigning tasks to callback functions.
Fields§
§output: String
test-runner
only.When test-runner
feature is active, contains the output
data from the previous command
info: String
test-runner
only.When test-runner
feature is active, contains the info
data from the previous command
warn: String
test-runner
only.When test-runner
feature is active, contains the warn
data from the previous command
error: String
test-runner
only.When test-runner
feature is active, contains the error
data from the previous command
success: String
test-runner
only.When test-runner
feature is active, contains the success
data from the previous command
async_output: Arc<Mutex<String>>
test-runner
only.When test-runner
feature is active, contains the async_output
data from the previous command
Implementations§
source§impl<State> ClapCmd<State>where
State: Clone,
impl<State> ClapCmd<State>where State: Clone,
sourcepub fn with_state(state: State) -> Selfwhere
State: Send + Sync + 'static,
pub fn with_state(state: State) -> Selfwhere State: Send + Sync + 'static,
Generate a default ClapCmd
instance with the specified initial State
sourcepub fn builder() -> ClapCmdBuilder
pub fn builder() -> ClapCmdBuilder
Generate a ClapCmdBuilder
object used mainly to expose rustyline settings
sourcepub fn unset_state(&mut self)
pub fn unset_state(&mut self)
Delete the internal state
sourcepub fn get_state_mut(&mut self) -> Option<&mut State>
pub fn get_state_mut(&mut self) -> Option<&mut State>
Retrieve a mutable reference to the current state from a callback
sourcepub fn set_prompt(&mut self, prompt: &str)
pub fn set_prompt(&mut self, prompt: &str)
Set the current prompt
sourcepub fn set_continuation_prompt(&mut self, continuation_prompt: &str)
pub fn set_continuation_prompt(&mut self, continuation_prompt: &str)
Set the continuation prompt
sourcepub fn has_command(&self, command: &str) -> bool
pub fn has_command(&self, command: &str) -> bool
Checks if a given &str is connected to a command
sourcepub fn add_command(&mut self, callback: impl Callback<State>, command: Command)
pub fn add_command(&mut self, callback: impl Callback<State>, command: Command)
Adds the specified command to the default group
sourcepub fn remove_command(&mut self, command: &str)
pub fn remove_command(&mut self, command: &str)
Removes the command distinguished by the string command
sourcepub fn group(name: &str) -> HandlerGroup<State>
pub fn group(name: &str) -> HandlerGroup<State>
Creates a new group that can be loaded an unloaded
sourcepub fn unnamed_group() -> HandlerGroup<State>
pub fn unnamed_group() -> HandlerGroup<State>
Creates a new unnamed group that can be loaded an unloaded
sourcepub fn add_group(&mut self, groups: &HandlerGroup<State>)
pub fn add_group(&mut self, groups: &HandlerGroup<State>)
Adds all the commands in a group
sourcepub fn remove_group(&mut self, groups: &HandlerGroup<State>)
pub fn remove_group(&mut self, groups: &HandlerGroup<State>)
Removes all the commands in a group
sourcepub fn get_async_writer(&mut self) -> Result<impl Write, Box<dyn Error>>
pub fn get_async_writer(&mut self) -> Result<impl Write, Box<dyn Error>>
Returns a thread-safe Write
object that can be used to asyncronously write output to stdout
without interferring with the promptline
sourcepub fn read_line(&mut self, prompt: &str) -> Option<String>
pub fn read_line(&mut self, prompt: &str) -> Option<String>
Creates a prompt and reads a single line from the user
sourcepub fn one_cmd(&mut self, line: &str) -> ClapCmdResult
pub fn one_cmd(&mut self, line: &str) -> ClapCmdResult
Executes the appropriate command(s) specified by the line read from the user