Extract command-line parsing into a testable function in lib.rs #19
Resolved by Extract command-line parsing into a testable function in lib.rs #24, merged by g1tCurrently src/main.rs reads the name straight from env::args().nth(1). Add to src/lib.rs a pub struct Options { pub name: Option<String> } and pub fn parse_args<I: IntoIterator<Item = String>>(args: I) -> Options (args excludes the program name). Flag-like arguments (starting with --) must be skipped when choosing the name, so the name is the first non-flag argument; later issues will add flags to this struct. Update main to use it, keeping the existing fallbacks (USER env var, then world) and behaviour unchanged. Add unit tests in src/lib.rs for: no args, a name, and a leading unknown --flag followed by a name.
Definition of done
cargo buildpasses.cargo testpasses.
Pull requests
1 for this issue