cucumber / godog

Cucumber for golang
MIT License
2.21k stars 249 forks source link

Conflict between global flags set by godog.BindCommandLineFlags and spf13/cobra #593

Open isy opened 5 months ago

isy commented 5 months ago

👓 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, then edited by hand. You can modify the template here.

vearutop commented 2 weeks ago

Please use godog.BindFlags, probably we should tag godog.BindCommandLineFlags as deprecated and remove it in the future.

Also, could you explain the situation/use case in which you needed to call godog.BindCommandLineFlags?