Fix cf completion

- fix a lot of broken syntax
This commit is contained in:
Shohei YOSHIDA 2026-03-08 22:08:49 +09:00
parent 324622c0d7
commit 85543dcb35
No known key found for this signature in database
GPG Key ID: C9A1BB11BB940CF2
1 changed files with 79 additions and 58 deletions

135
src/_cf
View File

@ -38,117 +38,130 @@
# Output a selectable list of organizations # Output a selectable list of organizations
__cf_orgs() { __cf_orgs() {
declare -a cont_cmd declare -a cont_cmd
cont_cmd=($(CF_COLOR=false CF_TRACE=false cf orgs | awk 'NR>3{print $1}')) cont_cmd=($(CF_COLOR=false CF_TRACE=false cf orgs | awk 'NR>3{print $1}'))
if [[ 'X$cont_cmd' != 'X' ]] if [[ "X$cont_cmd" != 'X' ]]; then
_describe 'ORG' cont_cmd _describe 'ORG' cont_cmd
fi
} }
# Output a selectable list of spaces # Output a selectable list of spaces
__cf_spaces() { __cf_spaces() {
declare -a cont_cmd declare -a cont_cmd
cont_cmd=($(CF_COLOR=false CF_TRACE=false cf spaces | awk 'NR>3{print $1}')) cont_cmd=($(CF_COLOR=false CF_TRACE=false cf spaces | awk 'NR>3{print $1}'))
if [[ 'X$cont_cmd' != 'X' ]] if [[ "X$cont_cmd" != 'X' ]]; then
_describe 'SPACE' cont_cmd _describe 'SPACE' cont_cmd
fi
} }
# Output a selectable list of applications # Output a selectable list of applications
__cf_apps() { __cf_apps() {
declare -a cont_cmd declare -a cont_cmd
cont_cmd=($(CF_COLOR=false CF_TRACE=false cf apps | awk 'NR>4{print $1}')) cont_cmd=($(CF_COLOR=false CF_TRACE=false cf apps | awk 'NR>4{print $1}'))
if [[ 'X$cont_cmd' != 'X' ]] if [[ "X$cont_cmd" != 'X' ]]; then
_describe 'APP' cont_cmd _describe 'APP' cont_cmd
fi
} }
# Output a selectable list of stacks # Output a selectable list of stacks
__cf_stacks() { __cf_stacks() {
declare -a cont_cmd declare -a cont_cmd
cont_cmd=($(CF_COLOR=false CF_TRACE=false cf stacks | awk 'NR>4{print $1}')) cont_cmd=($(CF_COLOR=false CF_TRACE=false cf stacks | awk 'NR>4{print $1}'))
if [[ 'X$cont_cmd' != 'X' ]] if [[ "X$cont_cmd" != 'X' ]]; then
_describe 'STACK' cont_cmd _describe 'STACK' cont_cmd
fi
} }
# Output a selectable list of services # Output a selectable list of services
__cf_marketplace_services() { __cf_marketplace_services() {
declare -a cont_cmd declare -a cont_cmd
cont_cmd=($(CF_COLOR=false CF_TRACE=false cf marketplace | awk 'NR>4{print $1}')) cont_cmd=($(CF_COLOR=false CF_TRACE=false cf marketplace | awk 'NR>4{print $1}'))
if [[ 'X$cont_cmd' != 'X' ]] if [[ "X$cont_cmd" != 'X' ]]; then
_describe 'SERVICE' cont_cmd _describe 'SERVICE' cont_cmd
fi
} }
# Output a selectable list of services # Output a selectable list of services
__cf_services() { __cf_services() {
declare -a cont_cmd declare -a cont_cmd
cont_cmd=($(CF_COLOR=false CF_TRACE=false cf services | awk 'NR>4{print $1}')) cont_cmd=($(CF_COLOR=false CF_TRACE=false cf services | awk 'NR>4{print $1}'))
if [[ 'X$cont_cmd' != 'X' ]] if [[ "X$cont_cmd" != 'X' ]]; then
_describe 'SERVICE' cont_cmd _describe 'SERVICE' cont_cmd
fi
} }
# Output a selectable list of domains # Output a selectable list of domains
__cf_domains() { __cf_domains() {
declare -a cont_cmd declare -a cont_cmd
cont_cmd=($(CF_COLOR=false CF_TRACE=false cf domains | grep -v shared | awk 'NR>2{print $1}')) cont_cmd=($(CF_COLOR=false CF_TRACE=false cf domains | grep -v shared | awk 'NR>2{print $1}'))
if [[ 'X$cont_cmd' != 'X' ]] if [[ "X$cont_cmd" != 'X' ]]; then
_describe 'DOMAIN' cont_cmd _describe 'DOMAIN' cont_cmd
fi
} }
# Output a selectable list of shared domains # Output a selectable list of shared domains
__cf_shared_domains() { __cf_shared_domains() {
declare -a cont_cmd declare -a cont_cmd
cont_cmd=($(CF_COLOR=false CF_TRACE=false cf domains | grep -v owned | awk 'NR>2{print $1}')) cont_cmd=($(CF_COLOR=false CF_TRACE=false cf domains | grep -v owned | awk 'NR>2{print $1}'))
if [[ 'X$cont_cmd' != 'X' ]] if [[ "X$cont_cmd" != 'X' ]]; then
_describe 'SHARED-DOMAIN' cont_cmd _describe 'SHARED-DOMAIN' cont_cmd
fi
} }
# Output a selectable list of hostnames # Output a selectable list of hostnames
__cf_hostnames() { __cf_hostnames() {
declare -a cont_cmd declare -a cont_cmd
cont_cmd=($(CF_COLOR=false CF_TRACE=false cf routes | awk 'NR>3{print $2}')) cont_cmd=($(CF_COLOR=false CF_TRACE=false cf routes | awk 'NR>3{print $2}'))
if [[ 'X$cont_cmd' != 'X' ]] if [[ "X$cont_cmd" != 'X' ]]; then
_describe 'ROUTE' cont_cmd _describe 'ROUTE' cont_cmd
fi
} }
# Output a selectable list of buildpacks # Output a selectable list of buildpacks
__cf_buildpacks() { __cf_buildpacks() {
declare -a cont_cmd declare -a cont_cmd
cont_cmd=($(CF_COLOR=false CF_TRACE=false cf buildpacks | awk 'NR>3{print $1}')) cont_cmd=($(CF_COLOR=false CF_TRACE=false cf buildpacks | awk 'NR>3{print $1}'))
if [[ 'X$cont_cmd' != 'X' ]] if [[ "X$cont_cmd" != 'X' ]]; then
_describe 'BUILDPACK' cont_cmd _describe 'BUILDPACK' cont_cmd
fi
} }
# Output a selectable list of feature flags # Output a selectable list of feature flags
__cf_feature_flags() { __cf_feature_flags() {
declare -a cont_cmd declare -a cont_cmd
cont_cmd=($(CF_COLOR=false CF_TRACE=false cf feature-flags | awk 'NR>4{print $1}')) cont_cmd=($(CF_COLOR=false CF_TRACE=false cf feature-flags | awk 'NR>4{print $1}'))
if [[ 'X$cont_cmd' != 'X' ]] if [[ "X$cont_cmd" != 'X' ]]; then
_describe 'FEATURE-FLAG' cont_cmd _describe 'FEATURE-FLAG' cont_cmd
fi
} }
# Output a selectable list of plugin repos # Output a selectable list of plugin repos
__cf_repo_plugins() { __cf_repo_plugins() {
declare -a cont_cmd declare -a cont_cmd
cont_cmd=($(CF_COLOR=false CF_TRACE=false cf list-plugin-repos | awk 'NR>3{print $1}')) cont_cmd=($(CF_COLOR=false CF_TRACE=false cf list-plugin-repos | awk 'NR>3{print $1}'))
if [[ 'X$cont_cmd' != 'X' ]] if [[ "X$cont_cmd" != 'X' ]]; then
_describe 'REPO-PLUGIN' cont_cmd _describe 'REPO-PLUGIN' cont_cmd
fi
} }
# Output a selectable list of plugins # Output a selectable list of plugins
__cf_plugins() { __cf_plugins() {
declare -a cont_cmd declare -a cont_cmd
cont_cmd=($(cf plugins | awk 'NR>4{print $1}')) cont_cmd=($(cf plugins | awk 'NR>4{print $1}'))
if [[ 'X$cont_cmd' != 'X' ]] if [[ "X$cont_cmd" != 'X' ]]; then
_describe 'PLUGIN' cont_cmd _describe 'PLUGIN' cont_cmd
fi
} }
# Output a selectable list of targets (requires cf-targets plugin) # Output a selectable list of targets (requires cf-targets plugin)
__cf_targets() { __cf_targets() {
declare -a cont_cmd declare -a cont_cmd
cont_cmd=($(cf targets | awk '{print $1}')) cont_cmd=($(cf targets | awk '{print $1}'))
if [[ 'X$cont_cmd' != 'X' ]] if [[ "X$cont_cmd" != 'X' ]]; then
_describe 'TARGET' cont_cmd _describe 'TARGET' cont_cmd
fi
} }
# -------------------------- # --------------------------
# ----- end Helper functions # ----- end Helper functions
# -------------------------- # --------------------------
@ -992,3 +1005,11 @@ case "$words[1]" in
delete-target) delete-target)
__delete-target ;; __delete-target ;;
esac esac
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et