has_flag 0.1.1

Check if args has a specific flag
Documentation
  • Coverage
  • 50%
    1 out of 2 items documented1 out of 1 items with examples
  • Size
  • Source code size: 7.06 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.02 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • suuzhh/has_flag_rust
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • SuZHui

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