Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bash completions for OS X #1539

Merged
merged 1 commit into from
Oct 2, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 12 additions & 15 deletions misc/completions/bash/kubecfg
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,14 @@ _kubecfg()
-h
-c
)
local -A all_services=(
[CREATE]="pods replicationControllers services"
[UPDATE]="replicationControllers"
[ALL]="pods replicationControllers services minions"
)
local services=(${all_services[ALL]})
local -A all_commands=(
[WITH_JSON]="create update"
[ALL]="create update get list delete stop rm rollingupdate resize"
)
local commands=(${all_commands[ALL]})
local create_services=(pods replicationControllers services)
local update_services=(replicationControllers)
local all_services=(pods replicationControllers services minions)
local services=("${all_services[@]}")

local json_commands=(create update)
local all_commands=(create update get list delete stop rm rollingupdate resize)
local commands=("${all_commands[@]}")

COMPREPLY=()
local command
Expand All @@ -155,8 +152,8 @@ _kubecfg()

# if you passed -c, you are limited to create or update
if __contains_word "-c" "${words[@]}"; then
services=(${all_services[CREATE]} ${all_services[UPDATE]})
commands=(${all_commands[WITH_JSON]})
services=("${create_services[@]}" "${update_services[@]}")
commands=("${json_commands[@]}")
fi

# figure out which command they are running, remembering that arguments to
Expand All @@ -179,9 +176,9 @@ _kubecfg()

# remove services which you can't update given your command
if [[ ${command} == "create" ]]; then
services=(${all_services[CREATE]})
services=("${create_services[@]}")
elif [[ ${command} == "update" ]]; then
services=(${all_services[UPDATE]})
services=("${update_services[@]}")
fi

case $command in
Expand Down