From: Ted Pavlic Date: Tue, 20 Jan 2009 00:46:12 +0000 (-0500) Subject: Modify bash completion to support help, version, and copyright. X-Git-Tag: v0.15-rc1~51 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/stgit/commitdiff_plain/e22e6f480424f733fd910d96b0fcbfeee4520f69 Modify bash completion to support help, version, and copyright. "stg " lists all commands, including "help", "version", and "copyright". "stg he" completes "stg help " "stg ver" completes "stg version " "stg copy" completes "stg copyright " "stg help " lists all commands /other than/ help, version, and copyright. "stg version " goes directly to shell completion. "stg copyright " goes directly to shell completion. Signed-off-by: Ted Pavlic Signed-off-by: Karl Hasselström --- diff --git a/stgit/completion.py b/stgit/completion.py index affc8c6..b3fd282 100644 --- a/stgit/completion.py +++ b/stgit/completion.py @@ -111,13 +111,19 @@ def main_switch(commands): ('# Complete name of subcommand if the user has not finished' ' typing it yet.'), 'if test $c -eq $COMP_CWORD -a -z "$command"; then', [ - ('COMPREPLY=($(compgen -W "$_stg_commands" --' + ('COMPREPLY=($(compgen -W "help version copyright $_stg_commands" --' ' "${COMP_WORDS[COMP_CWORD]}"))'), 'return'], 'fi', '', '# Complete arguments to subcommands.', 'case "$command" in', [ + 'help) ', [ + ('COMPREPLY=($(compgen -W "$_stg_commands" --' + ' "${COMP_WORDS[COMP_CWORD]}"))'), + 'return ;;'], + 'version) return ;;', + 'copyright) return ;;'], [ '%s) _stg_%s ;;' % (cmd, cmd) for cmd in sorted(commands.iterkeys())], 'esac')