1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
/*! A simple argument parsing library. # Lifetimes `'def`: `argument definition` The lifetime of argument definition passed to `parse` `'tar`: `target` The lifetime of target pointers used when defining arguments. */ #![feature(conservative_impl_trait)] #![feature(unicode)] extern crate std_unicode; mod argdef; mod help; mod parse; pub use argdef::{ArgDef, SingleTarget, CollectionTarget, OptionTarget}; pub use parse::{parse, parse_plain, ParseError}; /* DESIGN: Do I wait with assigning values until all arguments have been 'satisfied'? Or do I just start parsing/assigning as soon as possible so that bad arguments are caught faster? For now it'll be 2, since that seems simpler # option 1 read through the arguments and assign each to a matching option if an interrupt is encountered: run the callback and return the interrupt validate each argument (add 'validate' to the interface) go through and parse every value into its target return success */ /* Tasks Optional - Implement a validate->assign->modify procedure in parse - Make a passthrough argument (cargo run -- --help) - Add examples to README and library top-level documentation - Add tests Done - Usage generator (printer) - Help generator (printer) - Simple subcommand abstraction - Validate 'short' identifiers - Change default parse function to write usage (no parse_subcommand) - Implement multi-target for all std::collections - Let parse results pass either Option<i32> or Option<T> to facilitate 'outer' abort. - Make a 'collect' argument (gcc -i foo.h -i bar.h) Abandoned - Make a default handler function for parse results. */