Complete these tasks to reinforce what you learned in this module.
Use clap (derive) to define a CLI with: one positional argument path (required), and two flags --verbose (short -v, bool) and --dry-run (bool, default false). Parse args and print the path, verbose, and dry-run values.
Parser on a struct. A field without #[arg(...)] is a positional argument; use #[arg(short, long)] for flags. Call Args::parse() to get the parsed values.// Task 1: Flags and positional arg. See tasks/TASKS.md.
fn main() {
todo!("clap Parser: path (positional), --verbose, --dry-run");
}
Define a CLI with one subcommand: greet that takes an optional --name (default "World"). So: task_02 greet prints "Hello, World!" and task_02 greet --name Rust prints "Hello, Rust!". Use Subcommand and an enum with one variant Greet { name: Option<String> } or a struct with default.
Subcommand on an enum; one variant can have a field with #[arg(long, default_value = "World")]. In main, parse the top-level Parser struct that contains the subcommand, then match on it.// Task 2: Subcommand greet. See tasks/TASKS.md.
fn main() {
todo!("clap Subcommand: greet --name [default World]");
}