Skip to content

Commit

Permalink
add auto-completion stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas committed Jan 11, 2013
1 parent d652957 commit 69d3ac0
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
vcstool enables batch commands on multiple different vcs repositories. \
Currently it supports git, hg, svn and bzr.''',
license='BSD',
data_files=[
('share/vcstool-completion', [
'vcstool-completion/vcs.bash',
'vcstool-completion/vcs.tcsh',
'vcstool-completion/vcs.zsh'
])
],
entry_points={
'console_scripts': [
'vcs = vcstool.commands.vcs:main',
Expand Down
12 changes: 12 additions & 0 deletions vcstool-completion/vcs.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function _vcs()
{
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}

if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W "`vcs --commands`" -- $cur ))
fi
}

complete -o dirnames -F _vcs vcs
1 change: 1 addition & 0 deletions vcstool-completion/vcs.tcsh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
complete vcs 'p/1/`vcs --commands`/' 'C/*/d/'
12 changes: 12 additions & 0 deletions vcstool-completion/vcs.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function _vcs()
{
local opts
reply=()

if [[ ${CURRENT} == 2 ]]; then
opts=`vcs --commands`
reply=(${=opts})
fi
}

compctl -K "_vcs" "vcs"
5 changes: 5 additions & 0 deletions vcstool/commands/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def main(args=None):
print(' %s' % client.type)
return 0

if ns.commands:
print(' '.join([cmd.command for cmd in vcstool_commands]))
return 0

# output detailed command list
parser = get_parser_with_command_only()
parser.print_help()
Expand All @@ -42,6 +46,7 @@ def get_parser(add_help=True):
group = parser.add_mutually_exclusive_group()
group.add_argument('command', metavar='<command>', nargs='?', help='The available commands: %s' % ', '.join([cmd.command for cmd in vcstool_commands]))
group.add_argument('--clients', action='store_true', default=False, help='Show the available VCS clients')
group.add_argument('--commands', action='store_true', default=False, help='Output the available commands for auto-completion')
from vcstool import __version__
group.add_argument('--version', action='version', version='%(prog)s ' + __version__, help='Show the vcstool version')
return parser
Expand Down

0 comments on commit 69d3ac0

Please sign in to comment.