rust-ape-example/src/bin/std_misc_arg.rs
2022-09-07 10:49:49 +05:30

22 lines
463 B
Rust

// ./src/std_misc/arg.md
use std::env;
fn part0() {
let args: Vec<String> = env::args().collect();
// The first argument is the path that was used to call the program.
println!("My path is {}.", args[0]);
// The rest of the arguments are the passed command line parameters.
// Call the program like this:
// $ ./args arg1 arg2
println!("I got {:?} arguments: {:?}.", args.len() - 1, &args[1..]);
}
pub fn main() {
part0();
}