[AJUDA] Rodando a lib CLAP no rust
Olá Pessoal. Estou tentando rodar um código que vi na documentação do rust que usa a lib do clap para passar argumentos no terminal:
use clap::Parser;
/// Simple program to greet a person
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
/// Name of the person to greet
#[arg(short, long)]
name: String,
/// Number of times to greet
#[arg(short, long, default_value_t = 1)]
count: u8,
}
fn main() {
let args = Args::parse();
for _ in 0..args.count {
println!("Hello {}!", args.name)
}
}
eu rodei o comando para adicionar as dependências:
cargo add clap --features derive
Mas obtive o erro:
error: cannot find attribute `command` in this scope
--> src/main.rs:5:3
|
5 | #[command(version, about, long_about = None)]
| ^^^^^^^
error: cannot find attribute `arg` in this scope
--> src/main.rs:8:7
|
8 | #[arg(short, long)]
| ^^^
error: cannot find attribute `arg` in this scope
--> src/main.rs:12:7
|
12 | #[arg(short, long, default_value_t = 1)]
| ^^^
Quem souber e puder me dar um help, obrigado!