args_flags_1 0.2.0

A library for manipulating with flags
Documentation
  • Coverage
  • 68.75%
    11 out of 16 items documented9 out of 16 items with examples
  • Size
  • Source code size: 7.64 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.87 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • merlin-codes

Args flags

This project is trying to simplify the process of making CLI program. it will detect flag for your program and give you ways to have access to list of Flag the program is receiving.

Example

imports:

use args_flags_1::{FlagDetect, StaticFlagOnly, StaticFlag, Flag};

use (one prefix):

let flags: Vec<Flag> = StaticFlag::get("-", std::env::args());

use of more than one prefix (Beta):

let flags: Vec<Flag> = StaticFlag::getn(vec!["--", "-"], std::env::args());

use static version

only flags:

let prefix: &str = "-";

let flags: Vec<String> = StaticFlag::get(prefix, std::env::args());
let flags: Vec<String> = StaticFlag::getn(vec![prefix], std::env::args());

flags:

let prefix: &str = "-";

let flags: Vec<Flag> = StaticFlag::get(prefix, std::env::args());
let flags: Vec<Flag> = StaticFlag::getn(vec![prefix], std::env::args());

use with struct (no static):

let prefix: &str = "-";
let args: std::env::Args = std::env::args();
let detect: FlagDetect = FlagDetect::new(prefix).from_args(args);

// gives back value of the flag
let s_flag: Option<String> = detect.find("-s");
match s_flag {
    Some(x) => {},
    None => {}
}