Added long opt parsing, now understands -- and parses non-option elements into cmdarg_argv. Docs updated.
This commit is contained in:
37
tests/test_dashdash.sh
Normal file
37
tests/test_dashdash.sh
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/bash4
|
||||
|
||||
source $(dirname ${BASH_SOURCE[0]})/../cmdarg.sh
|
||||
|
||||
function shunittest_dashdash
|
||||
{
|
||||
set -x
|
||||
cmdarg_purge
|
||||
cmdarg_parse -- lolzors something
|
||||
[[ "${cmdarg_argv[0]}" == "lolzors" ]] || return 1
|
||||
[[ "${cmdarg_argv[1]}" == "something" ]] || return 1
|
||||
}
|
||||
|
||||
function shunittest_missing_dashdash
|
||||
{
|
||||
set -x
|
||||
cmdarg_purge
|
||||
( cmdarg_parse --lolzors ) || return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
function shunittest_withbool_missing_dashdash
|
||||
{
|
||||
set -x
|
||||
cmdarg_purge
|
||||
cmdarg 'x' 'xray' 'thingy for xray'
|
||||
( cmdarg_parse -x lolzors ) || return 0
|
||||
cmdarg_parse -x -- lolzors
|
||||
}
|
||||
|
||||
function shunittest_withopt_with_dashdash
|
||||
{
|
||||
set -x
|
||||
cmdarg_purge
|
||||
cmdarg 'x:' 'xray' 'thingy for xray'
|
||||
( cmdarg_parse -x -- lolzors ) || return 0
|
||||
}
|
||||
Reference in New Issue
Block a user