Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Cargo Script (github.com/rust-lang)
2 points by jcbhmr on Feb 26, 2024 | hide | past | favorite | 1 comment


https://doc.rust-lang.org/cargo/reference/unstable.html#scri...

Lets you do this:

    #!/usr/bin/env -S cargo +nightly -Zscript
    ```cargo
    [dependencies]
    clap = { version = "4.2", features = ["derive"] }
    ```
    
    use clap::Parser;
    
    #[derive(Parser, Debug)]
    #[clap(version)]
    struct Args {
        #[clap(short, long, help = "Path to config")]
        config: Option<std::path::PathBuf>,
    }
    
    fn main() {
        let args = Args::parse();
        println!("{:?}", args);
    }




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: