pub struct Console { /* private fields */ }Expand description
Application CLI console built around a binary name and named commands.
Implementations§
Source§impl Console
impl Console
Sourcepub fn new(binary_name: impl Into<String>) -> Self
pub fn new(binary_name: impl Into<String>) -> Self
Create a console whose help text uses binary_name.
Sourcepub fn about(self, about: impl Into<String>) -> Self
pub fn about(self, about: impl Into<String>) -> Self
Short description printed above the usage block.
Sourcepub fn serve<F, Fut>(self, handler: F) -> Selfwhere
F: Fn(CommandContext<'_>) -> Fut + Send + Sync + 'static,
Fut: Future<Output = CommandResult> + Send + 'static,
pub fn serve<F, Fut>(self, handler: F) -> Selfwhere
F: Fn(CommandContext<'_>) -> Fut + Send + Sync + 'static,
Fut: Future<Output = CommandResult> + Send + 'static,
Register the built-in serve command that starts the HTTP application.
Sourcepub fn commands(self, commands: impl IntoIterator<Item = CommandEntry>) -> Self
pub fn commands(self, commands: impl IntoIterator<Item = CommandEntry>) -> Self
Append user-registered commands from commands! or a manual list.
Sourcepub async fn run(self) -> CommandResult
pub async fn run(self) -> CommandResult
Parse process argv and dispatch.
§Errors
Returns an error for unknown commands or when a command fails.
Sourcepub async fn run_argv(
self,
argv: impl IntoIterator<Item = impl Into<String>>,
) -> CommandResult
pub async fn run_argv( self, argv: impl IntoIterator<Item = impl Into<String>>, ) -> CommandResult
Parse an explicit argv (including argv0) and dispatch.
§Errors
Returns an error for unknown commands or when a command fails.
Auto Trait Implementations§
impl !RefUnwindSafe for Console
impl !UnwindSafe for Console
impl Freeze for Console
impl Send for Console
impl Sync for Console
impl Unpin for Console
impl UnsafeUnpin for Console
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more