about
11/25/2022
RustCmdLine Repository
RustCmdLine Repository
Parse console command line arguments
Quick Status
Concept:
/p "rs,txt" - file patterns
/s - recurse through directory tree rooted at path
/H - hide directories that don't contain target files
/r "abc" - regular expression
Design:
-
new() -> Self Create newCmdLineParser which has an options hashmap, patterns vector, and help string. -
parse(&self) Builds internal options hashmap and patterns vector. -
path(&self) -> String Return value of relative root path, held in options map. -
abs_path(&self) -> String Return value of absolute root path, from canonicalized relative path. -
set_path(&mut self, p:&str) Replaces value of root path, held in options map. -
set_regex(&mut self, re:&str) Replaces value of regex string, held in options map. -
get_regex(&mut self) -> &str Retrieves value of regex string, held in options map. -
default_options(&mut self) Sets values of some of the options in options map. -
contains_option(&self, opt:char) -> bool returns true if options map contains key opt, else returns false. -
add_option(&mut self, opt:char, val:&str) Inserts option in options hashmap, adding key if it does not exist, else overriding previous value. -
value(&self, opt:char) -> &str Inserts option in options hashmap, adding key if it does not exist, else overriding previous value. -
add_pattern(&mut self, patt:&str) -> &mut self Inserts patt into patterns vector. Method can be chained. -
patterns(&self) -> &CmdLinePatterns Returns reference to vector of patterns. -
options(&self) -> &Options Returns reference to hashmap of options. -
help(&self) -> &str Returns default help string. -
replace_help(&mut self, hs:&str) Replace internal help string.
Operation:
Build:
Status:
Tested on both Windows 10 and Ubuntu Linux