-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic bash completion script and framework for others
- Loading branch information
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
_vmfloaty() | ||
{ | ||
local cur prev subcommands template_subcommands hostname_subcommands | ||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
prev="${COMP_WORDS[COMP_CWORD-1]}" | ||
|
||
subcommands="delete get help list modify query revert snapshot ssh status summary token" | ||
template_subcommands="get ssh" | ||
hostname_subcommands="delete modify query revert snapshot" | ||
|
||
if [[ $template_subcommands =~ (^| )$prev($| ) ]] ; then | ||
if [ -z "$_vmfloaty_avail_templates" ] ; then | ||
_vmfloaty_avail_templates=`floaty list` | ||
fi | ||
|
||
COMPREPLY=( $(compgen -W "${_vmfloaty_avail_templates}" -- ${cur}) ) | ||
elif [[ $hostname_subcommands =~ (^| )$prev($| ) ]] ; then | ||
_vmfloaty_active_hostnames=`floaty list --active | grep '^-' | cut -d' ' -f2` | ||
COMPREPLY=( $(compgen -W "${_vmfloaty_active_hostnames}" -- ${cur}) ) | ||
else | ||
COMPREPLY=( $(compgen -W "${subcommands}" -- ${cur}) ) | ||
fi | ||
} | ||
complete -F _vmfloaty floaty |
This file contains 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