2 ms·
the clever way to parse `-help` is to treat it as multiple options, but design your argument handler so that the `help` handler short-circuits and doesn't do an
by pphysch 5y ago
the clever way to parse `-help` is to treat it as multiple options, but design your argument handler so that the `help` handler short-circuits and doesn't do anything except output help text and exit (i.e. it reads '-h' then calls the help handler and exits, doesn't matter if -e isn't a valid option).
- oneeyedpigeon 5y agoWouldn't that make it awkward to combine help with any other option? I guess that's an edge case, but still...
- pphysch 5y agoMost commands IME will have this short-circuit behavior $ cmd --with -a --lot -of --options (fails) $ cmd --with -a --lot -of --options --help (behaves as if --help was the only option) From a terminal perspective, up-arrow + space + -h is often the fewest keystrokes to get what I want