0

I'm trying to add subcommands to my CLI tool in rust, using the clap library. When I copy the subcommand example from the docs

#[derive(clap::Parser)]
struct Args {
    #[command(subcommand)]
    action: Action,
}

#[derive(clap::Subcommand)]
enum Action {
    Add,
    Remove,
}

I get the following error:

error[E0277]: the trait bound `Action: FromStr` is not satisfied
|     action: Action,
|     ^^^^^^ the trait `FromStr` is not implemented for `Action`

Is the example from the docs broken?

Simon Berens
  • 554
  • 4
  • 11

0 Answers0