#command-line-arguments #parse #handle #programs

argser

Allows you to easily parse and handle CLI-Arguments

5 releases

0.2.3 Aug 25, 2021
0.2.2 Aug 25, 2021
0.2.1 Aug 5, 2021
0.2.0 Aug 4, 2021
0.1.0 Aug 4, 2021

#46 in #handle

MIT license

18KB
416 lines

Argser

A library to handle configuration for Programs

Examples

Simple Use-Case

  • name: The Name

Code

use argser::argser;

#[argser]
struct Options {
    name: String,
}

fn main() {
    let opts: Options = argser::parse_cli().unwrap();

    println!("Hello {}", opts.name);
}

Using Subcategories

  • name: The Name
  • con.domain: The Domain
  • con.port: The Port

Code

use argser::argser;

#[argser]
struct Options {
	name: String,
	#[argser(subcategory)]
	con: Connection,
}

#[argser]
struct Connection {
	domain: String,
	port: u16,
}

fn main() {
  let opts: Options = argser::parse_cli().unwrap();

  println!("Hello {}", opts.name);
	println!("Connecting to {}:{}", opts.con.domain, opts.con.port);
}

Dependencies

~1.5MB
~37K SLoC