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
|
unset discardme
|
||||||
subcommand=${1}
|
subcommand=${1}
|
||||||
if [[ -z $subcommand ]]; then
|
if [[ -z $subcommand ]]; then
|
||||||
subcommand="__default"
|
subcommand="__empty"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z ${(k)option_subcommands[$subcommand]} ]]; then
|
if [[ -z ${(k)option_subcommands[$subcommand]} ]]; then
|
||||||
_warning "There's no such command \"::1 subcommand::\"." $subcommand
|
subcommand="__unknown:$subcommand"
|
||||||
_failure "Please try -h for help."
|
# _warning "There's no such command \"::1 subcommand::\"." $subcommand
|
||||||
return 1
|
# _failure "Please try -h for help."
|
||||||
fi
|
fi
|
||||||
argv=("${(@)oldstar}")
|
argv=("${(@)oldstar}")
|
||||||
unset oldstar
|
unset oldstar
|
||||||
|
|
@ -981,7 +981,7 @@ option.parse() {
|
||||||
option_params+=$arg
|
option_params+=$arg
|
||||||
done
|
done
|
||||||
# First parameter actually is the subcommand: delete it and shift
|
# 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
|
### End parsing command-specific options
|
||||||
|
|
||||||
|
|
@ -998,7 +998,7 @@ option.parse() {
|
||||||
# help)
|
# help)
|
||||||
# print "TODO: help"
|
# print "TODO: help"
|
||||||
# ;;
|
# ;;
|
||||||
# __default)
|
# __empty)
|
||||||
# zdump
|
# zdump
|
||||||
# ;;
|
# ;;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,10 @@ tmpfiles=()
|
||||||
config_section=()
|
config_section=()
|
||||||
config_section_type=${config_section_type:-org-mode}
|
config_section_type=${config_section_type:-org-mode}
|
||||||
|
|
||||||
|
option_subcommands[__empty]=""
|
||||||
|
option_subcommands[__unknown]=""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func "Zuper $zuper_version initialized"
|
func "Zuper $zuper_version initialized"
|
||||||
func "${#vars} global variables registered"
|
func "${#vars} global variables registered"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue