Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions _shellcomp/volt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
get_plugs() {
local profile=$1
case "$2" in
all) all_plugs ;;
this) this_plug "$profile" ;;
not) comm -23 <(all_plugs) <(this_plug "$profile") ;;
*) echo ;;
esac
}

all_plugs() {
volt list -f "{{ range .Repos }}{{ println .Path }}{{ end }}" | sed -E 's@^(www\.)?github\.com/@@' | sort -u
}

this_plug() {
volt list -f "{{ range .Profiles }}{{ if eq \"$1\" .Name }}{{ range .ReposPath }}{{ println . }}{{ end }}{{ end }}{{ end }}" | sed -E 's@^(www\.)?github\.com/@@' | sort -u
}

CMDS="get rm list enable disable profile build migrate self-upgrade version"
PROFILE_CMDS="set show list new destroy rename add rm"
MIGRATE_CMDS="lockjson plugconf/config-func"

_volt() {
COMPREPLY=()
local cur="${COMP_WORDS[COMP_CWORD]}"
local first="${COMP_WORDS[1]}"
local second="${COMP_WORDS[2]}"
local third="${COMP_WORDS[3]}"

if [[ "${first}" == "profile" && ${second} =~ ^(set|show|list|new|destroy|rename|add|rm)$ && ${third} == "" ]] ; then
local profiles=$(volt profile list | sed 's/[* ] //')
COMPREPLY=( $(compgen -W "$(echo $profiles)" -- ${cur}) )
return 0
elif [[ "${first}" == "profile" && ${second} == "add" && ${third} ]] ; then
plugs=$(get_plugs "$third" "not")
COMPREPLY=( $(compgen -W "${plugs}" -- ${cur}) )
return 0
elif [[ "${first}" == "profile" && ${second} == "rm" && ${third} ]] ; then
plugs=$(get_plugs "$third" "this")
COMPREPLY=( $(compgen -W "${plugs}" -- ${cur}) )
return 0
elif [[ "${first}" == "profile" && "${third}" == "" ]] ; then
COMPREPLY=( $(compgen -W "${PROFILE_CMDS}" -- ${cur}) )
return 0
elif [[ "${first}" =~ ^(rm|disable)$ ]] ; then
local profile=$(volt list -f '{{ .CurrentProfileName }}')
plugs=$(get_plugs "$profile" "this")
COMPREPLY=( $(compgen -W "${plugs}" -- ${cur}) )
return 0
elif [[ "${first}" =~ ^(get|enable)$ ]] ; then
local profile=$(volt list -f '{{ .CurrentProfileName }}')
plugs=$(get_plugs "$profile" "not")
COMPREPLY=( $(compgen -W "${plugs}" -- ${cur}) )
return 0
elif [[ "${first}" == "migrate" ]] ; then
COMPREPLY=( $(compgen -W "${MIGRATE_CMDS}" -- ${cur}) )
return 0
elif [[ "${third}" == "" ]] ; then
COMPREPLY=( $(compgen -W "${CMDS}" -- ${cur}) )
return 0
fi
}
complete -F _volt volt
4 changes: 3 additions & 1 deletion plugconf/plugconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@ func ParsePlugconf(file *ast.File, src []byte, path string) (*ParsedInfo, *Parse
return true
}
parseErr.mwarn = multierror.Append(parseErr.mwarn,
errors.New("s:config() is deprecated. please use s:on_load_pre() instead"))
errors.New("s:config() is deprecated. "+
"please use s:on_load_pre() instead, or run "+
"\"volt migrate plugconf/config-func\" to rewrite existing plugconf files"))
if !isEmptyFunc(fn) {
onLoadPreFunc = string(extractBody(fn, src))
onLoadPreFunc = rxFuncName.ReplaceAllString(
Expand Down