No description
Find a file
2021-10-02 00:03:18 +02:00
examples readme 2021-10-02 00:03:18 +02:00
src os string handling 2021-10-01 23:56:41 +02:00
.gitignore initial commit 2021-09-20 14:37:49 +02:00
Cargo.toml initial commit 2021-09-20 14:37:49 +02:00
LICENSE Create LICENSE 2021-09-20 15:35:47 +02:00
README.md readme 2021-10-02 00:03:18 +02:00

badargs

A zero-dependency full type-safe argument parser.

badargs handles non Utf8 input by just printing an error and exiting the program gracefully.

How to use

use badargs::arg;

arg!(OutFile: "output", 'o' -> String);
arg!(Force: "force", 'f' -> bool);
arg!(OLevel: "optimize" -> usize);

fn main() {
    let args = badargs::badargs!(OutFile, Force, OLevel);

    let outfile = args.get::<OutFile>();
    let force = args.get::<Force>();
    let o_level = args.get::<OLevel>();

    println!("output:     {:?}", outfile);
    println!("force:      {:?}", force);
    println!("o-level:    {:?}", o_level);
    println!("other args: {:?}", args.unnamed())
    
}

Use the badargs::arg! macro to declare arguments like this:
arg!(Binding, long_name, optional_short_name -> return_type)

The following return types are currently available:

  • String
  • bool
  • isize
  • usize

Boolean values can only be None or Some.
The other values can be None or Some(_)