A command handler works with clap-derive
to generating subcommand handlers.
```rust use clap::{Parser, AppSettings}; use clap_handler::{Handler, handler, Context};
pub struct Arguments { #[clap(subcommand)] subcommand: Subcommand, }
pub enum Subcommand { First(FirstSubcommand), }
impl Subcommand { fn addsomething(&self, ctx: &mut Context) -> anyhow::Result<()> { // insert something // ctx.insert(astruct); Ok(()) } }
pub struct FirstSubcommand { arg: String, }
fn handle_first(me: FirstSubcommand) -> anyhow::Result<()> { Ok(()) }
fn main() { let args = Arguments::parse(); log::debug!("{:#?}", args); args.run().await } ```
For more complex examples, see the anni
and sswa
.
Licensed under either of
at your option.