-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-merge for PR #801 via VersionBot
add bash completions
- Loading branch information
Showing
4 changed files
with
82 additions
and
1 deletion.
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
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,73 @@ | ||
#!/bin/bash | ||
|
||
_resin_complete() | ||
{ | ||
local cur prev | ||
|
||
# Valid top-level completions | ||
commands="app apps build config deploy device devices env envs help key \ | ||
keys local login logout logs note os preload quickstart settings \ | ||
signup ssh sync util version whoami" | ||
# Sub-completions | ||
app_cmds="create restart rm" | ||
config_cmds="generate inject read reconfigure write" | ||
device_cmds="identify init move public-url reboot register rename rm \ | ||
shutdown" | ||
device_public_url_cmds="disable enable status" | ||
env_cmds="add rename rm" | ||
key_cmds="add rm" | ||
local_cmds="configure flash logs push scan ssh stop" | ||
os_cmds="build-config configure download initialize versions" | ||
util_cmds="available-drives" | ||
|
||
|
||
COMPREPLY=() | ||
cur=${COMP_WORDS[COMP_CWORD]} | ||
prev=${COMP_WORDS[COMP_CWORD-1]} | ||
|
||
if [ $COMP_CWORD -eq 1 ] | ||
then | ||
COMPREPLY=( $(compgen -W "${commands}" -- $cur) ) | ||
elif [ $COMP_CWORD -eq 2 ] | ||
then | ||
case "$prev" in | ||
"app") | ||
COMPREPLY=( $(compgen -W "$app_cmds" -- $cur) ) | ||
;; | ||
"config") | ||
COMPREPLY=( $(compgen -W "$config_cmds" -- $cur) ) | ||
;; | ||
"device") | ||
COMPREPLY=( $(compgen -W "$device_cmds" -- $cur) ) | ||
;; | ||
"env") | ||
COMPREPLY=( $(compgen -W "$env_cmds" -- $cur) ) | ||
;; | ||
"key") | ||
COMPREPLY=( $(compgen -W "$key_cmds" -- $cur) ) | ||
;; | ||
"local") | ||
COMPREPLY=( $(compgen -W "$local_cmds" -- $cur) ) | ||
;; | ||
"os") | ||
COMPREPLY=( $(compgen -W "$os_cmds" -- $cur) ) | ||
;; | ||
"util") | ||
COMPREPLY=( $(compgen -W "$util_cmds" -- $cur) ) | ||
;; | ||
"*") | ||
;; | ||
esac | ||
elif [ $COMP_CWORD -eq 3 ] | ||
then | ||
case "$prev" in | ||
"public-url") | ||
COMPREPLY=( $(compgen -W "$device_public_url_cmds" -- $cur) ) | ||
;; | ||
"*") | ||
;; | ||
esac | ||
fi | ||
|
||
} | ||
complete -F _resin_complete resin |