Implement Bash/Zsh basic autocompletion

This commit is contained in:
Juan Cruz Viotti 2014-12-24 09:15:27 -04:00
parent a9f721784b
commit 8624ff74d9
4 changed files with 146 additions and 1 deletions

41
completion/resin.sh Normal file
View File

@ -0,0 +1,41 @@
_resin() {
COMPREPLY=()
local current="${COMP_WORDS[COMP_CWORD]}"
local previous="${COMP_WORDS[COMP_CWORD-1]}"
local options="app device key envs os example"
case "${previous}" in
app)
local subcommands="create rm restart"
COMPREPLY=( $(compgen -W "${subcommands}" -- ${current}) )
return 0 ;;
device)
local subcommands="rename rm identify"
COMPREPLY=( $(compgen -W "${subcommands}" -- ${current}) )
return 0 ;;
key)
local subcommands="add rm"
COMPREPLY=( $(compgen -W "${subcommands}" -- ${current}) )
return 0 ;;
envs)
local subcommands="add rename rm"
COMPREPLY=( $(compgen -W "${subcommands}" -- ${current}) )
return 0 ;;
os)
local subcommands="download"
COMPREPLY=( $(compgen -W "${subcommands}" -- ${current}) )
return 0 ;;
example)
local subcommands="clone"
COMPREPLY=( $(compgen -W "${subcommands}" -- ${current}) )
return 0 ;;
*)
;;
esac
COMPREPLY=( $(compgen -W "${options}" -- ${current}) )
return 0
}
complete -F _resin resin

34
doc/resin-completion.1.md Normal file
View File

@ -0,0 +1,34 @@
resin(1) - tab completion for resin
===================================
## DESCRIPTION
It provides basic completion capabilities for `zsh` and `bash`.o
If you're using `bash`, add the following line to your `~/.bashrc`:
. /path/to/resin/completion/resin.sh.
or create a symlink like this if you have automatic bash completion set up:
ln - /path/to/resin/completion/resin.sh /etc/bash-completion.d/resin
or, perhaps:
ln - /path/to/resin/completion/resin.sh /usr/local/etc/bash-completion.d/resin
If you're using `zsh`, add the following to your `~/.zshrc`:
autoload bashcompinit
bashcompinit
source /path/to/resin/completion/resin.sh
## RESIN PATH
`/path/to/resin` refers to the place where resin was globally installed in your system.
This is usually something like `/usr/lib/node_modules/resin`, or `C:\Users\AppData\Roaming\npm\node_modules\resin` on Windows.
## COPYRIGHT
resin is Copyright (C) 2014 Resin.io <https://resin.io>

View File

@ -0,0 +1,69 @@
.\" Generated with Ronnjs 0.4.0
.\" http://github.com/kapouer/ronnjs
.
.TH "RESIN" "1" "December 2014" "" ""
.
.SH "NAME"
\fBresin\fR \-\- tab completion for resin
.
.SH "DESCRIPTION"
It provides basic completion capabilities for \fBzsh\fR and \fBbash\fR\|\.o
.
.P
If you\'re using \fBbash\fR, add the following line to your \fB~/\.bashrc\fR:
.
.IP "" 4
.
.nf
\|\. /path/to/resin/completion/resin\.sh\.
.
.fi
.
.IP "" 0
.
.P
or create a symlink like this if you have automatic bash completion set up:
.
.IP "" 4
.
.nf
ln \- /path/to/resin/completion/resin\.sh /etc/bash\-completion\.d/resin
.
.fi
.
.IP "" 0
.
.P
or, perhaps:
.
.IP "" 4
.
.nf
ln \- /path/to/resin/completion/resin\.sh /usr/local/etc/bash\-completion\.d/resin
.
.fi
.
.IP "" 0
.
.P
If you\'re using \fBzsh\fR, add the following to your \fB~/\.zshrc\fR:
.
.IP "" 4
.
.nf
autoload bashcompinit
bashcompinit
source /path/to/resin/completion/resin\.sh
.
.fi
.
.IP "" 0
.
.SH "RESIN PATH"
\fB/path/to/resin\fR refers to the place where resin was globally installed in your system\.
.
.P
This is usually something like \fB/usr/lib/node_modules/resin\fR, or \fBC:\\Users\\AppData\\Roaming\\npm\\node_modules\\resin\fR on Windows\.
.
.SH "COPYRIGHT"
resin is Copyright (C) 2014 Resin\.io \fIhttps://resin\.io\fR

View File

@ -9,7 +9,8 @@
},
"preferGlobal": true,
"man": [
"./doc/resin.1.roff"
"./doc/resin.1.roff",
"./doc/resin-completion.1.roff"
],
"bin": {
"resin": "./bin/resin"