flagtory

Crates.ioflagtory
lib.rsflagtory
version0.2.1
sourcesrc
created_at2022-12-29 14:39:01.160127
updated_at2022-12-30 23:59:52.644008
descriptiona simple library to make command line flags.
homepagehttps://github.com/akbarilmnn/flagtory
repositoryhttps://github.com/akbarilmnn/flagtory
max_upload_size
id747377
size12,246
Muhammad Akbar ilman Setijadi (akbarilmnn)

documentation

README

Crates.io Documentation dependency status

Flagtory

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.

Examples

    // 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.

Commit count: 12

cargo fmt