cobra
cobra copied to clipboard
A Commander for modern Go CLI interactions
Today we have `cobra.OnInitialize` but unfortunately we don't have an API to return initialization errors. This aims to add `cobra.OnInitializeE` to accept `func() error` and returns error accordingly.
Previously, a command such as: &cobra.Command{Use: "run/first [OPTIONS] arg1 arg2"} would fail generation with an error "no such file or directory" because the generating code would expect some directory ending...
Resolves https://github.com/spf13/cobra/issues/1633
I was going through the user-guide which I'm not sure I had read through and through before. These are small ajustements I noticed were needed.
We added a `fig-autocomplete` hidden subcommand to Infracost and it increased the padding in the usage text (https://github.com/infracost/infracost/pull/1457#discussion_r827182625), which was unexpected. This fixes any hidden commands affecting the padding: Fixes...
os.Exit(1) kill process without defering functions. panic can be recover if needed. Signed-off-by: Guilhem Lettron
I've defined a subcommand with two boolean arguments and found it unexpectedly run into the subcommand. In specific, a subcommand naming "sub" with two boolean arguments "a" and "b". If...
The code below doesn't really need the `error` as return type, so I remove it ```go func printOptions(buf *bytes.Buffer, cmd *cobra.Command, name string) error { flags := cmd.NonInheritedFlags() flags.SetOutput(buf) if...