Cobra: Obsolete bash completion example (kubernetes)... and use a better example anyway

Created on 12 Jun 2017  路  7Comments  路  Source: spf13/cobra

The current [bash_completions.md]
(https://github.com/spf13/cobra/blob/master/bash_completions.md)

  • uses a very complex example (kubernetes) and also
  • Has the wrong import ("github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd"
    ) and code (it's shifted over time)

And it might be best to scale back the initial statement "is incredibly easy", since I'm a seasoned developer and can make no sense of the example at all, as it uses custom kube stuff that has moved around and doesn't seem relevant.

A basic example on a simpler go repo would work a lot better.

Thanks!

are*sh completion aredocumentation kinstale

All 7 comments

Of course this is really easy. In our situation, we have a command RootCmd which has all the other commands added to it. Seems like an easy example like this could just be included. Works perfectly, thanks.

func main() {
    err := cmd.RootCmd.GenBashCompletionFile("bin/ddev_completion.sh")

    util.CheckErr(err)
}

/cc @eparis

@rfay Ha. Hard to argue. I wrote the bash completions stuff so I could use it in kube. At the time it seemed so 'simple'. I'd love a PR that makes an actually simple example.

it may be simple, but it is not self-explanatory. would be helpful to have an explanation of how to generalize it to my own command.

It would be great if someone could provide an auto-completion example for a custom command :)

+1 would love to see a generic example

This issue is being marked as stale due to a long period of inactivity

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mdaymard picture mdaymard  路  5Comments

umbynos picture umbynos  路  5Comments

diwakergupta picture diwakergupta  路  5Comments

phanirithvij picture phanirithvij  路  5Comments

joernott picture joernott  路  6Comments