-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Making initCompleteCmd exported so completion commands can be documented #1464
Comments
Hi @gssbzn. I am not too familiar with the REST generation provided by Cobra. If I try calling I realize the Cobra documentation gives examples of REST generation that don't use That being said, if we need to support generating REST without calling Line 63 in de187e8
Finally, you should know that the "completion" command is not created if there are no subcommands, so even with the above changes, I don't believe the example will include the "completion" command; you'd have to create a subcommand first. |
Hi @marckhouzam thanks for looking into this, so expanding to a more complete example, the one I gave was basically from the docs but we've been documenting our commands before, completion included as we used to do it manually but since the change to the dynamic ones introduced in the latest cobra and now those files are no longer generated. Full example cmd := &cobra.Command{
Use: "test",
Short: "my test program",
}
subcmd := &cobra.Command{
Use: "sub-test",
Short: "my test command",
Run: func(cmd *cobra.Command, args []string) {
log.Println("test")
},
}
cmd.AddCommand(subcmd)
if err := doc.GenReSTTree(cmd, "./docs/command"); err != nil {
log.Fatal(err)
} it will only generate the Explicitly calling I think I'll go ahead and make |
This issue is being marked as stale due to a long period of inactivity |
I'd also like I have done the same to the For reference the alterations I want to do:
|
Right now if you try to generate documentation the usual way
Will not generate docs for the auto generated completion command, an alternative to get it to work would be to alter the example to
but this will cause to init the help command which the current behaviour (I believe) is ok on not documentingIs there any reasons why
initCompleteCmd
is not exported and could we make it so so I can replace_, _ = cmd.ExecuteC()
with a call to just that function when documenting commands?InitDefaultHelpCmd
seems to be exported so we would be aligning with that behaviourHappy to make a PR if this is ok to change
Edit: this condition
cobra/doc/rest_docs.go
Line 146 in de187e8
initCompleteCmd
to make this more focused to what's neededThe text was updated successfully, but these errors were encountered: