-
Notifications
You must be signed in to change notification settings - Fork 0
/
dnx
25 lines (23 loc) · 863 Bytes
/
dnx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
_dnx_completion()
{
local cur prev opts command help
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
help="-? -h --help"
opts="$help --version --watch --packages --configuration --port"
if [ -f ${prev}/project.json ] ; then
# if there is a project.json in the folder specified by the previous argument
COMMANDS=$(cat $prev/project.json | python -c 'import json,sys;obj=json.load(sys.stdin);print(" ".join(key for key in obj["commands"].keys()))')
COMPREPLY=( $(compgen -W "$COMMANDS run" -- ${cur}) )
return 0
elif [ ${prev} == dnx ] ; then
# tab complete folder
COMPREPLY=( $(compgen -f ) )
return 0
else
# tab complete dnx options
COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
fi
}
complete -F _dnx_completion dnx