args_flags_1

Crates.ioargs_flags_1
lib.rsargs_flags_1
version0.2.0
sourcesrc
created_at2022-11-25 23:26:17.207715
updated_at2023-01-08 15:36:05.897152
descriptionA library for manipulating with flags
homepage
repository
max_upload_size
id723005
size8,110
Miloslav Štekrt (MiloslavStekrt)

documentation

README

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 => {}
}
Commit count: 0

cargo fmt