tailhook / rust-argparse

The command-line argument parser library for rust
MIT License
240 stars 39 forks source link

Space after comma in help #52

Open cdutsov opened 4 years ago

cdutsov commented 4 years ago

It would be nicer if it prints a space after the comma in the help. Now with --help the output is:

Optional arguments:
  -h,--help             Show this help message and exit
  -d,--dt DT            Dead-time duration (default 10 000), ns
  -L,--hw HW            Histogram size in channels (default: 1000)
  -s,--show-hist        Show time distribution histogram

and it would be nicer with:

Optional arguments:
  -h, --help             Show this help message and exit
  -d, --dt DT            Dead-time duration (default 10 000), ns
  -L, --hw HW            Histogram size in channels (default: 1000)
  -s, --show-hist        Show time distribution histogram

I think that the edit should be in src/parser.rs on line 864:

    pub fn print_option(&mut self, opt: &GenericOption<'b>) -> IoResult<()> {
        let mut num = 2;
        try!(write!(self.buf, "  "));
        let mut niter = opt.names.iter();
        let name = niter.next().unwrap();
        try!(write!(self.buf, "{}", name));
        num += name.len();
        for name in niter {
864:        try!(write!(self.buf, ","));  // <-- add a space here
            try!(write!(self.buf, "{}", name));
            num += name.len() + 1;
        }
...

Thank you for the great work and the nice crate! I prefer it to the other argument parsing crates because it is quite small and easy to use.