mirror of https://github.com/dyne/zuper.git
improved option parser with __empty and __unknown
This commit is contained in:
parent
7e70209e21
commit
d59b4d64cb
12
zuper
12
zuper
|
|
@ -942,13 +942,13 @@ option.parse() {
|
|||
unset discardme
|
||||
subcommand=${1}
|
||||
if [[ -z $subcommand ]]; then
|
||||
subcommand="__default"
|
||||
subcommand="__empty"
|
||||
fi
|
||||
|
||||
if [[ -z ${(k)option_subcommands[$subcommand]} ]]; then
|
||||
_warning "There's no such command \"::1 subcommand::\"." $subcommand
|
||||
_failure "Please try -h for help."
|
||||
return 1
|
||||
subcommand="__unknown:$subcommand"
|
||||
# _warning "There's no such command \"::1 subcommand::\"." $subcommand
|
||||
# _failure "Please try -h for help."
|
||||
fi
|
||||
argv=("${(@)oldstar}")
|
||||
unset oldstar
|
||||
|
|
@ -981,7 +981,7 @@ option.parse() {
|
|||
option_params+=$arg
|
||||
done
|
||||
# First parameter actually is the subcommand: delete it and shift
|
||||
[[ $subcommand != '__default' ]] && { option_params[1]=(); shift }
|
||||
[[ $subcommand != '__empty' ]] && { option_params[1]=(); shift }
|
||||
|
||||
### End parsing command-specific options
|
||||
|
||||
|
|
@ -998,7 +998,7 @@ option.parse() {
|
|||
# help)
|
||||
# print "TODO: help"
|
||||
# ;;
|
||||
# __default)
|
||||
# __empty)
|
||||
# zdump
|
||||
# ;;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ tmpfiles=()
|
|||
config_section=()
|
||||
config_section_type=${config_section_type:-org-mode}
|
||||
|
||||
option_subcommands[__empty]=""
|
||||
option_subcommands[__unknown]=""
|
||||
|
||||
|
||||
|
||||
func "Zuper $zuper_version initialized"
|
||||
func "${#vars} global variables registered"
|
||||
|
|
|
|||
Loading…
Reference in New Issue