1use anyhow::{Error, Result};
6 pub display_help: bool,
7 pub display_version: bool,
9 pub files: Vec<PathBuf>,
13 pub fn parse_args() -> Result<Args> {
14 let mut args = Args::default();
15 let argv: Vec<String> = std::env::args().collect();
16 let mut iter = argv.iter();
18 iter.next(); // skip the program, we don't care about that
20 for arg in &mut iter {
22 "--" => break, // stop parsing at this point treat the remaining as files
23 "--version" => args.display_version = true,
24 "--help" => args.display_help = true,
25 arg if arg.starts_with("--") => {
26 return Err(Error::msg(format!(
27 "unexpected double dash argument: {}",
31 arg if arg.starts_with('-') => {
32 let arg = arg.get(1..).unwrap().chars();
35 'v' => args.verbosity += 1,
36 'V' => args.display_version = true,
37 'h' => args.display_help = true,
38 _ => return Err(Error::msg(format!("unexpected short arg {}", chr))),
42 arg => args.files.push(PathBuf::from(arg)),
46 // push the remaining args, if any to the files
47 for filename in iter {
48 args.files.push(PathBuf::from(filename));
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list