Command line program with a single file parameter



examples/args/some-tool/src/main.rs
use std::env;
use std::process;

fn main() {
    let args: Vec<String> = env::args().collect();
    if args.len() != 2 {
        eprintln!("Usage: {} FILENAME", args[0]);
        process::exit(1);
    }

    let filename = &args[1];
    println!("We are working on file '{}'", filename);
}

cargo run

Usage: target/debug/some-tool FILENAME


cargo run data.csv

We are working on file 'data.csv'