Append = to long options requiring an argument
Make it obvious that the option expects an argument by appending the equal sign on completion. Suspend space in this case. The regular expression in `output-options.sh` is adjusted to take into account this on processing option strings.
This commit is contained in:
parent
09132ace80
commit
8feb9053ec
File diff suppressed because it is too large
Load Diff
@ -52,6 +52,11 @@ _hledger_completion_function() {
|
|||||||
# Replace dashes with underscores and use indirect expansion
|
# Replace dashes with underscores and use indirect expansion
|
||||||
subcommandOptions=_hledger_complist_options_${subcommand//-/_}
|
subcommandOptions=_hledger_complist_options_${subcommand//-/_}
|
||||||
_hledger_compreply "$(_hledger_compgen "${!subcommandOptions}")"
|
_hledger_compreply "$(_hledger_compgen "${!subcommandOptions}")"
|
||||||
|
|
||||||
|
# Suspend space on completion of long options requiring an argument
|
||||||
|
[[ ${COMPREPLY[0]} == --*= ]] && compopt -o nospace
|
||||||
|
compopt +o filenames
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
break
|
break
|
||||||
@ -64,6 +69,9 @@ _hledger_completion_function() {
|
|||||||
compopt +o filenames
|
compopt +o filenames
|
||||||
if [[ $cur == -* ]]; then
|
if [[ $cur == -* ]]; then
|
||||||
_hledger_compreply "$(_hledger_compgen "$_hledger_complist_generic_options")"
|
_hledger_compreply "$(_hledger_compgen "$_hledger_complist_generic_options")"
|
||||||
|
|
||||||
|
# Suspend space on completion of long options requiring an argument
|
||||||
|
[[ ${COMPREPLY[0]} == --*= ]] && compopt -o nospace
|
||||||
else
|
else
|
||||||
_hledger_compreply "$(_hledger_compgen "$_hledger_complist_commands")"
|
_hledger_compreply "$(_hledger_compgen "$_hledger_complist_commands")"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -17,7 +17,7 @@ main() {
|
|||||||
|
|
||||||
# Do not print '=' after long options with arg because it makes completion
|
# Do not print '=' after long options with arg because it makes completion
|
||||||
# for option arguments harder.
|
# for option arguments harder.
|
||||||
sed -rn 's/.* (--[a-zA-Z][-_a-zA-Z0-9]*)=?.*/\1/gp' < "$tmp"
|
sed -rn 's/.* (--[a-zA-Z][-_a-zA-Z0-9]*=?).*/\1/gp' < "$tmp"
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user