Conflict between global flags set by godog.BindCommandLineFlags and spf13/cobra
- Dominant language
- Go
- Stars
- 2.7k
- Forks
- 280
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 2
Description
### 👓 What did you see?
While testing my program which implemented a command with `spf13/cobra,` I received an error message that says "unable to redefine 'c' shorthand in "xxxxxxxxxx" flagset: it's already used for "xxxxxxxxxxxxx" flag".
The shorthand c in the global flags set by `godog.BindCommandLineFlags` was causing a collision with a shorthand c in my cobra command.
### ✅ What did you expect to see?
I expected the godog package to be compatible with my cobra command without any conflicts.
### 📦 Which tool/library version are you using?
v0.13.0
### 🔬 How could we reproduce it?
Steps to reproduce the behavior:
1.Install both godog and cobra
2.Create a Cobra command with a shorthand 'c'
3.Use godog.BindCommandLineFlags to bind global flags
4.Run the test command
5.You should see the error unable to redefine 'c' shorthand in "xxxxxxxxx" flagset: it's already used for "xxxxxxxxx" flag
### 📚 Any additional context?
Given that this collision is possible, it suggests that there may be an issue with godog's global flag setting feature that needs to be addressed. I wonder if there's a measure we can take on the godog side, such as not assigning shorthands to the global flags set by godog.BindCommandLineFlags.
I look forward to your thoughts and response. Thank you.
----
*This text was originally generated from a [template](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/about-issue-and-pull-request-templates), then edited by hand. [You can modify the template here.](https://github.com/cucumber/.github/edit/main/.github/ISSUE_TEMPLATE/bug_report.md)*
Contributor guide
Research direction
Start at godog.BindCommandLineFlags and reproduce the conflict with a Cobra command that uses shorthand 'c', following how the global flags are registered. The work is done when the command runs without the shorthand redefinition error and regression coverage demonstrates that this combination is handled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100