spf13 / cobra-cli

Cobra CLI tool to generate applications and commands

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[RFC] improve generated boilerplate

johnSchnake opened this issue · comments

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.

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.

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

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

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

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? 🙂

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

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

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