Replace Flags library alecthomas/kingpin with spf13/pflag
What would you like to be added:
✅ TL;DR
Use cobra for building modern, extensible CLI applications — especially if you want long-term support, Kubernetes-style UX, and active community backing.
Library spf13/cobra is in pretty much every kubernetes project https://github.com/search?q=org%3Akubernetes-sigs%20github.com%2Fspf13%2Fcobra&type=code
Avoid kingpin for projects. Although it offers a great developer experience, it is archived and no longer maintained.
Library kingpin only used in external-dns
Why is this needed:
⚔️ Comparing cobra vs kingpin for Go CLI Applications
📦 Feature Comparison
| Feature | cobra |
kingpin |
|---|---|---|
| Project Status | ✅ Actively maintained and widely used | ⚠️ Archived (read-only) |
| Subcommand support | ✅ First-class support with nested commands | ✅ Strong, elegant support |
| Help / Usage formatting | ✅ Customizable help output | ✅ Very clean help output |
| Flag parsing | ✅ Uses pflag for compatibility |
✅ Built-in (custom parsing) |
| Standard flag support | ✅ Compatible via pflag |
❌ Not compatible |
| Kubernetes adoption | ✅ Used by kubectl, controller-runtime, etc. |
❌ Not used |
| Command structure | ✅ Explicit tree structure | ✅ Declarative-style chain calls |
| Validation | ✅ Built-in validation | 🚫 Not supported out of the box (but possible) |
| Learning curve | 🟡 Slightly verbose at first | 🟢 Easy & readable |
| Last Update | ✅ 2+ month ago | ❌ 2+ years ago |
| Github Stars | ✅ 40k+ | 🟡 ~4k |
/kind deprecation
It makes sense to me. It's also used with TraefikLabs project ;).
Hi, if this is not taken yet then I would like to work on this.
@anshuman-agarwala Sure. PRs are welcome. /assign @anshuman-agarwala
HI @anshuman-agarwala are you planning to take a stab on that issue anytime soon?
Hi, really sorry for being a no show, I don't think I'll be able to get around to this anytime soon so it's better that I unassign myself. /unassign
What would be the next steps? We have introduced full parity between Cobra and Kingpin. Kingpin is still the default backend with a hidden switch to test the new Cobra-backend using EXTERNAL_DNS_CLI=cobra ENV-variable or the --cli-backend=cobra flag.
I suggest adding documentation for the new backend, along with an announcement that the default backend will be switched to Cobra at a certain release, if no conflicting feedback comes in. Let me know what you think