## page was renamed from Rust/CmdLnArgs = Rust - read input from command line = * cargo run -- arG1 {{{ #rust fn main() { // This fancy stuff either gets the first argument as a String, or prints // usage and exits if an argument was not supplied to the program. let mut arg: String = std::env::args().nth(1).unwrap_or_else(|| { println!("Please supply an argument to this program."); std::process::exit(-1); }); inspect(&arg); } }}} == Using CLAP cli rust crate == Links: [[https://rust-cli-recommendations.sunshowers.io/handling-arguments.html|clap-example]] [[https://stackoverflow.com/questions/71991935/how-to-make-a-default-subcommand-with-clap-and-derive|SO_71991935]] * Add to Cargo.toml {{{ [dependencies] clap = { version = "4.5.4", features = ["derive"] } }}}