argser

Crates.ioargser
lib.rsargser
version0.2.3
sourcesrc
created_at2021-08-04 18:05:09.500015
updated_at2021-08-25 19:24:44.35396
descriptionAllows you to easily parse and handle CLI-Arguments
homepage
repositoryhttps://github.com/Lol3rrr/argser
max_upload_size
id431646
size25,209
(Lol3rrr)

documentation

README

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);
}
Commit count: 19

cargo fmt