Skip to content

Commit

Permalink
Support container suggestions on some commands
Browse files Browse the repository at this point in the history
  • Loading branch information
c-bata committed Nov 2, 2019
1 parent 04dfaec commit 37f5b4c
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions kube/completer.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,30 @@ func (c *Completer) completeOptionArguments(d prompt.Document) ([]prompt.Suggest
if !found {
return []prompt.Suggest{}, false
}

// namespace
if option == "-n" || option == "--namespace" {
return prompt.FilterHasPrefix(
getNameSpaceSuggestions(c.namespaceList),
d.GetWordBeforeCursor(),
true,
), true
}

// filename
switch cmd {
case "get", "describe", "create", "delete", "replace", "patch",
"edit", "apply", "expose", "rolling-update", "rollout",
"label", "annotate", "scale", "convert", "autoscale", "top", "logs":
switch option {
case "-f", "--filename":
"label", "annotate", "scale", "convert", "autoscale", "top":
if option == "-f" || option == "--filename" {
return yamlFileCompleter.Complete(d), true
case "-n", "--namespace":
return prompt.FilterHasPrefix(
getNameSpaceSuggestions(c.namespaceList),
d.GetWordBeforeCursor(),
true,
), true
case "-c", "--container":
}
}

// container
switch cmd {
case "exec", "logs", "run", "attach", "port-forward", "cp":
if option == "-c" || option == "--container" {
cmdArgs := getCommandArgs(d)
var suggestions []prompt.Suggest
if cmdArgs == nil || len(cmdArgs) < 2 {
Expand Down

0 comments on commit 37f5b4c

Please sign in to comment.