cobra
cobra copied to clipboard
A Commander for modern Go CLI interactions
The error handler is a function that a user can define to handle errors in a custom way. The function will be called only if the error is received and...
Currently the Powershell completion script generated by Cobra does not work in [constrained mode](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_language_modes?view=powershell-5.1#constrainedlanguage-mode) because creating CompletionResult Objects is blocked there. This adds a check to the script that returns...
Fixes: #2188 Note: This PR fixes the same bug in two different code paths (`c.Find()` and `c.Traverse()`). They use different helper functions for parsing the arguments, but the fix is...
Found in cobra v1.8.1 (latest at time of writing) Reproduce: I execute the root command with a context ( ExecuteContext(ctx) ), my arguments resolve to a sub command and the...
Context is not copied from parent to child Comment on code states copy if parent has context but code implements copy if child doesn't have context Fix makes behaviour consistent...
Hello! In the cobra.dev website "https://cobra.dev/#using-the-cobra-generator" in the section "[Using the Cobra Generator](https://cobra.dev/#using-the-cobra-generator)" This link https://github.com/spf13/cobra/blob/master/cobra/README.md is broken!
Is there a recommended way to build an app using Cobra CLI that can be used both as a web server as well as a CLI? I am, primarily, looking...
How to reproduce: * Compile the following source code which defines some commands & flags (`go build ./mycli.go`): ```go package main import ( "fmt" "os" "github.com/spf13/cobra" ) var ( aFlag...
Long time supporter, first time caller! 👋 Wanted to solicit maintainers' insights into how users avoid conflicting commands. I appreciate any guidance offered! ❤ ### Problem As of `v1.8.1`, `Command.AddCommand(cmds...
Closes #2209, #2221 #2221 proposed a solution where the custom `DefaultShellCompDirective` only applied to a given command. In https://github.com/spf13/cobra/pull/2221#discussion_r1923845125, alternative approaches were discussed. We agreed on a recursive solution, where...