Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid option/parsing error should show help in addition to exception #49

Open
Pitterling opened this issue Mar 22, 2018 · 1 comment
Milestone

Comments

@Pitterling
Copy link

running the hello_world.sh example from the 1.2 doc with an invalid option throws the error and exits .. it would be better to show the help in addition?

# sh test.sh -x
flags:WARN getopt: invalid option -- 'x'
 --
flags:FATAL unable to parse provided options with getopt.

parsing error should show help

# sh test.sh -h
USAGE: test.sh [flags] args
flags:
  -d,--[no]debug:  enable debug mode (default: false)
  -h,--help:  show this help (default: false)
@kward
Copy link
Owner

kward commented Apr 13, 2020

Seems reasonable. Of the three semi-random command choices of grep, ls, and find that I tested on my macOS machine, all three provided usage info for an invalid argument. Setting to milestone 1.3.1.

[kward@kward-macpro13 2020-04-13T23:33:13 %0]~/var/wa/github.com/kward/shunit2
$ grep --asdf
grep: unrecognized option `--asdf'
usage: grep [-abcDEFGHhIiJLlmnOoqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
	[-e pattern] [-f file] [--binary-files=value] [--color=when]
	[--context[=num]] [--directories=action] [--label] [--line-buffered]
	[--null] [pattern] [file ...]

[kward@kward-macpro13 2020-04-13T23:33:39 %0]~/var/wa/github.com/kward/shunit2
$ ls --asdf
ls: illegal option -- -
usage: ls [-@ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1%] [file ...]

[kward@kward-macpro13 2020-04-13T23:33:42 %0]~/var/wa/github.com/kward/shunit2
$ find --asdf
find: illegal option -- -
usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]
       find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]

@kward kward added this to the 1.3.1 milestone Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants