Skip to content

Commit

Permalink
Merge pull request #507 from Dannyzen/master
Browse files Browse the repository at this point in the history
adding additional features to cloudfoundry cli
  • Loading branch information
Dannyzen committed May 22, 2017
2 parents 10609c1 + 8afa476 commit 01c69f3
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions src/_cf
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ __cf_plugins() {
_describe 'PLUGIN' cont_cmd
}

# Output a selectable list of targets (requires cf-targets plugin)
__cf_targets() {
declare -a cont_cmd
cont_cmd=($(cf targets | awk '{print $1}'))
if [[ 'X$cont_cmd' != 'X' ]]
_describe 'TARGET' cont_cmd
}


# --------------------------
# ----- end Helper functions
# --------------------------
Expand All @@ -153,8 +162,8 @@ __login() {
'-a=[API endpoint (e.g. https://api.example.com)]:api endpoint:' \
'-u=[Username]:username:' \
'-p=[Password]:password:' \
'-o=[Organization]:organization name:' \
'-s=[Space]:space name:' \
'-o=[Organization]:organization name:__cf_orgs' \
'-s=[Space]:space name:__cf_spaces' \
'--sso[Use a one-time password to login]' \
'--skip-ssl-validation[Skip SSL validation]'
}
Expand Down Expand Up @@ -197,8 +206,8 @@ __app() {

__push() {
_arguments \
'1:application name:' \
'-b=[Custom buildpack by name (e.g. my-buildpack) or GIT URL or GIT BRANCH URL]' \
'1:application name:__cf_apps' \
'-b=[Custom buildpack by name (e.g. my-buildpack) or GIT URL or GIT BRANCH URL]:buildpack name:__cf_buildpacks' \
'-c=[Startup command, set to null to reset to default start command]:startup command:' \
'-d=[Domain (e.g. example.com)]:domain (e.g. example.com):__cf_domains' \
'-f=[Path to manifest]:file:_files:' \
Expand Down Expand Up @@ -669,6 +678,23 @@ __uninstall-plugin() {
'1:plugin name:__cf_plugins'
}

__save-target() {
_arguments \
'1:target-name:' \
'-f[Force save even if current target is already saved under another name]'
}

__set-target() {
_arguments \
'1:target-name:__cf_targets' \
'-f[Force target change even if current target is unsaved]'
}

__delete-target() {
_arguments \
'1:target-name:__cf_targets'
}

# ------------------
# ----- end Commands
# ------------------
Expand Down Expand Up @@ -766,6 +792,10 @@ _1st_arguments=(
"plugins":"list all available plugin commands"
"install-plugin":"Install the plugin defined in command argument"
"uninstall-plugin":"Uninstall the plugin defined in command argument"
"targets":"List all saved targets (requires cf-targets plugin)"
"save-target":"Save the current target under a given name (requires cf-targets plugin)"
"set-target":"Restore a previously saved target (requires cf-targets plugin)"
"delete-target":"Delete a saved target (requires cf-targets plugin)"
)

# -----------------------
Expand Down Expand Up @@ -955,4 +985,10 @@ case "$words[1]" in
__install-plugin ;;
uninstall-plugin)
__uninstall-plugin ;;
save-target)
__save-target ;;
set-target)
__set-target ;;
delete-target)
__delete-target ;;
esac

0 comments on commit 01c69f3

Please sign in to comment.