Skip to content

Commit 168f462

Browse files
author
LingxianKong
committed
add bash completion script
This patch add a script mistral.bash_completion which enables auto-completion of mistral CLI in bash environmnet when running: python setup.py install or python setup.py develop test: mistral [tab][tab] mistral workf[tab][tab] mistral workflow-get -[tab][tab] Change-Id: I8e25f3a90c09e6f09877d9f66cc1f8aa44d6e6f6 Implements: blueprint add-bash-completion-script
1 parent f7b8b70 commit 168f462

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

setup.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ author-email = [email protected]
1919
packages =
2020
mistralclient
2121

22+
data_files =
23+
/etc/bash_completion.d =
24+
tools/mistral.bash_completion
25+
2226
[entry_points]
2327
console_scripts =
2428
mistral = mistralclient.shell:main

tools/mistral.bash_completion

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
_mistral()
4+
{
5+
declare -A SUBCOMMANDS
6+
declare -A OPTS
7+
8+
OPTS["action-create"]="-h --help -f --format -c --column --max-width --quote"
9+
OPTS["action-delete"]="-h --help"
10+
OPTS["action-get"]="-h --help -f --format -c --column --max-width --variable --prefix"
11+
OPTS["action-get-definition"]="-h --help"
12+
OPTS["action-list"]="-h --help -f --format -c --column --max-width --quote"
13+
OPTS["action-update"]="-h --help -f --format -c --column --max-width --quote"
14+
OPTS["complete"]="-h --help --name --shell"
15+
OPTS["cron-trigger-create"]="-h --help -f --format -c --column --max-width --variable --prefix"
16+
OPTS["cron-trigger-delete"]="-h --help"
17+
OPTS["cron-trigger-get"]="-h --help -f --format -c --column --max-width --variable --prefix"
18+
OPTS["cron-trigger-list"]="-h --help -f --format -c --column --max-width --quote"
19+
OPTS["environment-create"]="-h --help -f --format -c --column --max-width --variable --prefix"
20+
OPTS["environment-delete"]="-h --help"
21+
OPTS["environment-get"]="-h --help -f --format -c --column --max-width --variable --prefix"
22+
OPTS["environment-list"]="-h --help -f --format -c --column --max-width --quote"
23+
OPTS["environment-update"]="-h --help -f --format -c --column --max-width --variable --prefix"
24+
OPTS["execution-create"]="-h --help -f --format -c --column --max-width --variable --prefix"
25+
OPTS["execution-delete"]="-h --help"
26+
OPTS["execution-get"]="-h --help -f --format -c --column --max-width --variable --prefix"
27+
OPTS["execution-get-input"]="-h --help"
28+
OPTS["execution-get-output"]="-h --help"
29+
OPTS["execution-list"]="-h --help -f --format -c --column --max-width --quote"
30+
OPTS["execution-update"]="-h --help -f --format -c --column --max-width --variable --prefix"
31+
OPTS["help"]="-h --help"
32+
OPTS["task-get"]="-h --help -f --format -c --column --max-width --variable --prefix"
33+
OPTS["task-get-input"]="-h --help"
34+
OPTS["task-get-result"]="-h --help"
35+
OPTS["task-list"]="-h --help -f --format -c --column --max-width --quote"
36+
OPTS["task-update"]="-h --help -f --format -c --column --max-width --variable --prefix"
37+
OPTS["workbook-create"]="-h --help -f --format -c --column --max-width --variable --prefix"
38+
OPTS["workbook-delete"]="-h --help"
39+
OPTS["workbook-get"]="-h --help -f --format -c --column --max-width --variable --prefix"
40+
OPTS["workbook-get-definition"]="-h --help"
41+
OPTS["workbook-list"]="-h --help -f --format -c --column --max-width --quote"
42+
OPTS["workbook-update"]="-h --help -f --format -c --column --max-width --variable --prefix"
43+
OPTS["workflow-create"]="-h --help -f --format -c --column --max-width --quote"
44+
OPTS["workflow-delete"]="-h --help"
45+
OPTS["workflow-get"]="-h --help -f --format -c --column --max-width --variable --prefix"
46+
OPTS["workflow-get-definition"]="-h --help"
47+
OPTS["workflow-list"]="-h --help -f --format -c --column --max-width --quote"
48+
OPTS["workflow-update"]="-h --help -f --format -c --column --max-width --quote"
49+
50+
COMMANDS="${!OPTS[*]}"
51+
COMPREPLY=()
52+
53+
local cur="${COMP_WORDS[COMP_CWORD]}"
54+
local prev="${COMP_WORDS[COMP_CWORD-1]}"
55+
56+
if [[ $cur =~ (\.|\~|\/).* ]] ; then
57+
_filedir
58+
elif [ $COMP_CWORD == "1" ] ; then
59+
COMPREPLY=($(compgen -W "$COMMANDS" -- ${cur}))
60+
elif [ $COMP_CWORD == "2" ] ; then
61+
COMPREPLY=($(compgen -W "${OPTS[${prev}]}" -- ${cur}))
62+
fi
63+
return 0
64+
}
65+
complete -F _mistral mistral

0 commit comments

Comments
 (0)