Compare commits
No commits in common. "460cfe6254755a6ea40dbd671ed0f6a84af97abb" and "6694e1dde92309e1256177f39b290672a5ab255c" have entirely different histories.
460cfe6254
...
6694e1dde9
@ -23,7 +23,7 @@ if [[ "$1" == "version" ]];then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$1" == "--help" ]]; then
|
if [ "$1" == "--help" ]; then
|
||||||
print_help
|
print_help
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# If we are completing a flag, use Cobra's builtin completion system.
|
|
||||||
# To know if we are completing a flag we need the last argument starts with a `-` and does not contain an `=`
|
|
||||||
args=("$@")
|
|
||||||
lastArg=${args[((${#args[@]}-1))]}
|
|
||||||
if [[ "$lastArg" == -* ]]; then
|
|
||||||
if [[ "$lastArg" != *=* ]]; then
|
|
||||||
kubectl ns __complete "$@"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# TODO Make sure we are not completing the value of a flag.
|
|
||||||
# TODO Only complete a single argument.
|
|
||||||
# Both are pretty hard to do in a shell script. The better way to do this would be to let
|
|
||||||
# Cobra do all the completions by using `cobra.ValidArgsFunction` in the program.
|
|
||||||
# But the below, although imperfect, is a nice example for plugins that don't use Cobra.
|
|
||||||
|
|
||||||
kubectl get nodes --no-headers -o custom-columns=":metadata.name"
|
|
||||||
|
|
||||||
# Turn off file completion. See the ShellCompDirective documentation within
|
|
||||||
# https://github.com/spf13/cobra/blob/main/shell_completions.md#completion-of-nouns
|
|
||||||
echo :4
|
|
||||||
fi
|
|
Loading…
x
Reference in New Issue
Block a user