Created
January 8, 2013 23:44
-
-
Save gregorynicholas/4489161 to your computer and use it in GitHub Desktop.
autocomplete functionality for python library command line interfaces (CLI): Fabric & Paver.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
. paver_autocomplete | |
. fabric_autocomplete |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
_fab() | |
{ | |
local cur | |
COMPREPLY=() | |
# Variable to hold the current word | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
# Build a list of the available tasks from: `fab -l` | |
local cmds=$(fab -l 2>/dev/null | grep "^ " | awk '{print $1;}') | |
# Generate possible matches and store them in the | |
# array variable COMPREPLY | |
COMPREPLY=($(compgen -W "${cmds}" $cur)) | |
} | |
# Assign the auto-completion function for our command. | |
complete -F _fab fab |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
_paver() | |
{ | |
local cur | |
COMPREPLY=() | |
# Variable to hold the current word | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
# Build a list of the available tasks from: `paver --help --quiet` | |
local cmds=$(paver -hq | awk '/^ ([a-zA-Z][a-zA-Z0-9_]+)/ {print $1}') | |
# Generate possible matches and store them in the | |
# array variable COMPREPLY | |
COMPREPLY=($(compgen -W "${cmds}" $cur)) | |
} | |
# Assign the auto-completion function for our command. | |
complete -F _paver paver |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment