has_flag

Crates.iohas_flag
lib.rshas_flag
version0.1.1
sourcesrc
created_at2020-12-30 07:51:18.456059
updated_at2020-12-30 09:33:47.49819
descriptionCheck if args has a specific flag
homepagehttps://github.com/SuZHui/has_flag_rust
repositoryhttps://github.com/SuZHui/has_flag_rust
max_upload_size
id329155
size7,061
Zh-Hui Su (SuZHui)

documentation

https://docs.rs/has_flag/0.1.1/has_flag

README

has-flag-rust

Check if args has a specific flag.

IMPORTANT: This crate is base on has-flag, Thanks author for his efforts

Correctly stops looking after an -- argument terminator.

Usage

command input

ls -f --unicorn --foo=bar -- --rainbow
use has_flag::has_flag;
use env::args;

has_flag("unicorn", args().collect());
//=> true

has_flag ("--unicorn", args().collect());
//=> true

has_flag("f", args().collect());
//=> true

has_flag("-f", args().collect());
//=> true

has_flag("foo=bar", env::args().collect());
//=> true

has_flag("foo", env::args().collect());
//=> false

has_flag("rainbow", env::args().collect());
//=> false
Commit count: 17

cargo fmt