a simple library to make command line flags

3 unstable releases

0.2.1 Dec 30, 2022
0.2.0 Dec 30, 2022
0.1.0 Dec 29, 2022

#1143 in Command line utilities

MIT license

112 lines

Crates.io Documentation dependency status


a simple library to make command line flags. This library provides the user to make their own command line flags easily. This library's API model is inspired by Go's flag package which has a simple interface to the users.


    // bring the module into scope     
    use flagtory::Flags;

    // initialize the flags struct
    let flags = Flags::new();

    // add your flags using the add method 
    // this returns a mutable reference to the value 
    let bool_ref = flags.add("f","this is my flag", true);
    assert_eq!(*bool_ref, true);

    // you can change the value as long it's the same type 
    *bool_ref = false;

    assert_eq!(*bool_ref, false);

Currently, flagtory only accept values that implements the std::str::FromStr and std::any::Any trait. Which is wrapped by the Flag trait which is why &str is not implemented in the Flag trait, use String instead. and there are some limitations around how a user can create their own flags which is parsable. See here Please use the latest version to get the best experience.

No runtime deps