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

[RFC] improve generated boilerplate #12

Open
johnSchnake opened this issue Mar 1, 2022 · 8 comments
Open

[RFC] improve generated boilerplate #12

johnSchnake opened this issue Mar 1, 2022 · 8 comments
Labels
help wanted Extra attention is needed

Comments

@johnSchnake
Copy link
Collaborator

spf13/cobra#1614 (comment)

Multiple issues in the spf13/cobra repo were regarding the patterns of globals/init methods which made testing and growth difficult.

This linked issue properly points to the method (I think) most people eventually figure out for themselves.

Moved to this repo due to the CLI being split off.

@johnSchnake
Copy link
Collaborator Author

spf13/cobra#1290 was also an issue pointing out that data races were detected in that default app. This will be something we need to check when we re-write the sample.

@jxsl13
Copy link

jxsl13 commented Mar 1, 2022

#14 is a step forward.

  • I usually do call rootCmd.AddCommand(NewSubCommand()) inside of the constructor NewRootCmd() which would be quite hard to do with generated code. cobra-cli would need to actually parse generated Go code and append lines at specific locations for that to work with sub commands that are added afterwards.

@github-actions
Copy link

github-actions bot commented May 1, 2022

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

@github-actions
Copy link

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

@enrichman
Copy link

I've found this issue and RFC because I was going to open an issue/question about the init() func, and if it was possible to change the docs and user guide, and probably the generator (I've not used it, but I guess that it's going to generate the everything "globally".

I've found a really nice article on how to structure a Cobra application, and this is what I am using as a guidance at the moment: https://carolynvanslyck.com/blog/2020/08/sting-of-the-viper/

Is this RFC going to be implemented? Or what's the state of it? 🙂

@github-actions
Copy link

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

@github-actions
Copy link

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

@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
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants