Call with no args
$ optparsing_demo
--verbose: false
--filename: myfile
positional:
Call with both short and long options, as well as positional args
$ optparsing_demo --verbose -f test.txt foo
--verbose: true
--filename: test.txt
positional: foo
Call with -- to pass positionals that look like flags
$ optparsing_demo --filename=test.txt -- -v --verbose -f --filename are acceptable options
--verbose: false
--filename: test.txt
positional: -v --verbose -f --filename are acceptable options
Called incorrectly with positionals before intended opts
$ optparsing_demo do not put positionals before opts --verbose --filename=mynewfile
--verbose: false
--filename: myfile
positional: do not put positionals before opts --verbose --filename=mynewfile
This method of opt parsing does not support flag chaining like getopt does
$ optparsing_demo -vh
optparsing_demo: Unknown option '-vh'
Call with no args
$ zparseopts_demo
--verbose:
--filename: myfile
positional:
Call with both short and long options, as well as positional args
$ zparseopts_demo --verbose -f test.txt foo
--verbose: --verbose
--filename: test.txt
positional: foo
Call with -- to pass positionals that look like flags
$ zparseopts_demo --filename test.txt -- -v --verbose -f --filename are acceptable options
--verbose:
--filename: test.txt
positional: -v --verbose -f --filename are acceptable options
Called incorrectly with positionals before intended opts. If you want this, zparseopts supports it with the -E flag.
$ zparseopts_demo do not put positionals before opts --verbose --filename=mynewfile
--verbose:
--filename: myfile
positional: do not put positionals before opts --verbose --filename=mynewfile
This method of opt parsing does supports flag chaining like getopt does
$ zparseopts_demo -vh
zparseopts_demo [-h|--help]
zparseopts_demo [-v|--verbose] [-f|--filename=<file>] [<message...>]
This was helpful to me. Thanks!
Line 70 should be:
(
--filename
missing its second dash)