mirror of
https://github.com/ahgamut/rust-ape-example.git
synced 2024-05-15 01:52:42 +00:00
22 lines
463 B
Rust
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();
|
|
}
|
|
|