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

Obsolete bash completion example (kubernetes)... and use a better example anyway #465

Closed
rfay opened this issue Jun 12, 2017 · 7 comments
Closed
Labels
area/shell-completion All shell completions kind/documentation Documentation of cobra itself

Comments

@rfay
Copy link

rfay commented Jun 12, 2017

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!

@rfay
Copy link
Author

rfay commented Jun 12, 2017

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)
}

@n10v
Copy link
Collaborator

n10v commented Jun 13, 2017

/cc @eparis

@n10v n10v added area/shell-completion All shell completions kind/documentation Documentation of cobra itself labels Jun 13, 2017
n10v added a commit to n10v/cobra that referenced this issue Jun 13, 2017
@eparis
Copy link
Collaborator

eparis commented Jun 13, 2017

@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.

@dfong
Copy link

dfong commented Aug 15, 2017

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.

@menuka94
Copy link

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

@GodloveD
Copy link

+1 would love to see a generic example

Jason-Hendry added a commit to Jason-Hendry/cobra that referenced this issue Feb 6, 2018
eparis pushed a commit that referenced this issue May 31, 2018
@github-actions
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/shell-completion All shell completions kind/documentation Documentation of cobra itself
Projects
None yet
Development

No branches or pull requests

6 participants