From 8feb9053ec47dc3acd425e4f22cf9f669468999f Mon Sep 17 00:00:00 2001 From: Vladimir Zhelezov Date: Sat, 12 Dec 2020 10:47:15 +0100 Subject: [PATCH] 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. --- shell-completion/hledger-completion.bash | 970 ++++++++++---------- shell-completion/hledger-completion.bash.m4 | 8 + shell-completion/output-options.sh | 2 +- 3 files changed, 509 insertions(+), 471 deletions(-) diff --git a/shell-completion/hledger-completion.bash b/shell-completion/hledger-completion.bash index b8b678548..fa4670e95 100644 --- a/shell-completion/hledger-completion.bash +++ b/shell-completion/hledger-completion.bash @@ -52,6 +52,11 @@ _hledger_completion_function() { # Replace dashes with underscores and use indirect expansion subcommandOptions=_hledger_complist_options_${subcommand//-/_} _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 fi break @@ -64,6 +69,9 @@ _hledger_completion_function() { compopt +o filenames if [[ $cur == -* ]]; then _hledger_compreply "$(_hledger_compgen "$_hledger_complist_generic_options")" + + # Suspend space on completion of long options requiring an argument + [[ ${COMPREPLY[0]} == --*= ]] && compopt -o nospace else _hledger_compreply "$(_hledger_compgen "$_hledger_complist_commands")" fi @@ -420,22 +428,22 @@ tag: TEXT read -r -d "" _hledger_complist_generic_options <