Crates.io | flagtory |
lib.rs | flagtory |
version | 0.2.1 |
source | src |
created_at | 2022-12-29 14:39:01.160127 |
updated_at | 2022-12-30 23:59:52.644008 |
description | a simple library to make command line flags. |
homepage | https://github.com/akbarilmnn/flagtory |
repository | https://github.com/akbarilmnn/flagtory |
max_upload_size | |
id | 747377 |
size | 12,246 |
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.