Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clap says `cargo` feature flag is required - what does it mean?

Tags:

rust

clap

Here is my code in src/bin/foo.rs:

use clap::command;
pub fn main() {
  let matches = command!("foo")
    .about("Simple util")
    .get_matches();
}

I'm getting:

error: `cargo` feature flag is required
  --> src/bin/foo.rs:30:19
   |
30 |     let matches = command!("foo")
   |                   ^^^^^^^^^^^^^^^
   |
like image 649
yegor256 Avatar asked Sep 11 '25 19:09

yegor256


1 Answers

In your Cargo.toml file change your clap dependency to enable the cargo feature.

e.g.

clap = { version = "3.2.20", features = ["cargo"] }
like image 79
Rik Avatar answered Sep 14 '25 10:09

Rik