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
This commit is contained in:
		@@ -19,6 +19,10 @@ author-email = openstack-dev@lists.openstack.org
 | 
			
		||||
packages =
 | 
			
		||||
    mistralclient
 | 
			
		||||
 | 
			
		||||
data_files =
 | 
			
		||||
    /etc/bash_completion.d =
 | 
			
		||||
        tools/mistral.bash_completion
 | 
			
		||||
 | 
			
		||||
[entry_points]
 | 
			
		||||
console_scripts =
 | 
			
		||||
    mistral = mistralclient.shell:main
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										65
									
								
								tools/mistral.bash_completion
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								tools/mistral.bash_completion
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,65 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
_mistral()
 | 
			
		||||
{
 | 
			
		||||
    declare -A SUBCOMMANDS
 | 
			
		||||
    declare -A OPTS
 | 
			
		||||
 | 
			
		||||
    OPTS["action-create"]="-h --help -f --format -c --column --max-width --quote"
 | 
			
		||||
    OPTS["action-delete"]="-h --help"
 | 
			
		||||
    OPTS["action-get"]="-h --help -f --format -c --column --max-width --variable --prefix"
 | 
			
		||||
    OPTS["action-get-definition"]="-h --help"
 | 
			
		||||
    OPTS["action-list"]="-h --help -f --format -c --column --max-width --quote"
 | 
			
		||||
    OPTS["action-update"]="-h --help -f --format -c --column --max-width --quote"
 | 
			
		||||
    OPTS["complete"]="-h --help --name --shell"
 | 
			
		||||
    OPTS["cron-trigger-create"]="-h --help -f --format -c --column --max-width --variable --prefix"
 | 
			
		||||
    OPTS["cron-trigger-delete"]="-h --help"
 | 
			
		||||
    OPTS["cron-trigger-get"]="-h --help -f --format -c --column --max-width --variable --prefix"
 | 
			
		||||
    OPTS["cron-trigger-list"]="-h --help -f --format -c --column --max-width --quote"
 | 
			
		||||
    OPTS["environment-create"]="-h --help -f --format -c --column --max-width --variable --prefix"
 | 
			
		||||
    OPTS["environment-delete"]="-h --help"
 | 
			
		||||
    OPTS["environment-get"]="-h --help -f --format -c --column --max-width --variable --prefix"
 | 
			
		||||
    OPTS["environment-list"]="-h --help -f --format -c --column --max-width --quote"
 | 
			
		||||
    OPTS["environment-update"]="-h --help -f --format -c --column --max-width --variable --prefix"
 | 
			
		||||
    OPTS["execution-create"]="-h --help -f --format -c --column --max-width --variable --prefix"
 | 
			
		||||
    OPTS["execution-delete"]="-h --help"
 | 
			
		||||
    OPTS["execution-get"]="-h --help -f --format -c --column --max-width --variable --prefix"
 | 
			
		||||
    OPTS["execution-get-input"]="-h --help"
 | 
			
		||||
    OPTS["execution-get-output"]="-h --help"
 | 
			
		||||
    OPTS["execution-list"]="-h --help -f --format -c --column --max-width --quote"
 | 
			
		||||
    OPTS["execution-update"]="-h --help -f --format -c --column --max-width --variable --prefix"
 | 
			
		||||
    OPTS["help"]="-h --help"
 | 
			
		||||
    OPTS["task-get"]="-h --help -f --format -c --column --max-width --variable --prefix"
 | 
			
		||||
    OPTS["task-get-input"]="-h --help"
 | 
			
		||||
    OPTS["task-get-result"]="-h --help"
 | 
			
		||||
    OPTS["task-list"]="-h --help -f --format -c --column --max-width --quote"
 | 
			
		||||
    OPTS["task-update"]="-h --help -f --format -c --column --max-width --variable --prefix"
 | 
			
		||||
    OPTS["workbook-create"]="-h --help -f --format -c --column --max-width --variable --prefix"
 | 
			
		||||
    OPTS["workbook-delete"]="-h --help"
 | 
			
		||||
    OPTS["workbook-get"]="-h --help -f --format -c --column --max-width --variable --prefix"
 | 
			
		||||
    OPTS["workbook-get-definition"]="-h --help"
 | 
			
		||||
    OPTS["workbook-list"]="-h --help -f --format -c --column --max-width --quote"
 | 
			
		||||
    OPTS["workbook-update"]="-h --help -f --format -c --column --max-width --variable --prefix"
 | 
			
		||||
    OPTS["workflow-create"]="-h --help -f --format -c --column --max-width --quote"
 | 
			
		||||
    OPTS["workflow-delete"]="-h --help"
 | 
			
		||||
    OPTS["workflow-get"]="-h --help -f --format -c --column --max-width --variable --prefix"
 | 
			
		||||
    OPTS["workflow-get-definition"]="-h --help"
 | 
			
		||||
    OPTS["workflow-list"]="-h --help -f --format -c --column --max-width --quote"
 | 
			
		||||
    OPTS["workflow-update"]="-h --help -f --format -c --column --max-width --quote"
 | 
			
		||||
 | 
			
		||||
    COMMANDS="${!OPTS[*]}"
 | 
			
		||||
    COMPREPLY=()
 | 
			
		||||
 | 
			
		||||
    local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
			
		||||
    local prev="${COMP_WORDS[COMP_CWORD-1]}"
 | 
			
		||||
 | 
			
		||||
    if [[ $cur =~ (\.|\~|\/).* ]] ; then
 | 
			
		||||
        _filedir
 | 
			
		||||
    elif [ $COMP_CWORD == "1" ] ; then
 | 
			
		||||
        COMPREPLY=($(compgen -W "$COMMANDS" -- ${cur}))
 | 
			
		||||
    elif [ $COMP_CWORD == "2" ] ; then
 | 
			
		||||
        COMPREPLY=($(compgen -W "${OPTS[${prev}]}" -- ${cur}))
 | 
			
		||||
    fi
 | 
			
		||||
    return 0
 | 
			
		||||
}
 | 
			
		||||
complete -F _mistral mistral
 | 
			
		||||
		Reference in New Issue
	
	Block a user