external-dns icon indicating copy to clipboard operation
external-dns copied to clipboard

Replace Flags library alecthomas/kingpin with spf13/pflag

Open ivankatliarchuk opened this issue 11 months ago • 4 comments

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

ivankatliarchuk avatar May 11 '25 09:05 ivankatliarchuk

/kind deprecation

ivankatliarchuk avatar May 11 '25 18:05 ivankatliarchuk

It makes sense to me. It's also used with TraefikLabs project ;).

mloiseleur avatar May 14 '25 15:05 mloiseleur

Hi, if this is not taken yet then I would like to work on this.

anshuman-agarwala avatar May 15 '25 10:05 anshuman-agarwala

@anshuman-agarwala Sure. PRs are welcome. /assign @anshuman-agarwala

mloiseleur avatar May 15 '25 10:05 mloiseleur

HI @anshuman-agarwala are you planning to take a stab on that issue anytime soon?

ivankatliarchuk avatar Jul 07 '25 09:07 ivankatliarchuk

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

anshuman-agarwala avatar Aug 20 '25 15:08 anshuman-agarwala

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

TobyTheHutt avatar Sep 17 '25 10:09 TobyTheHutt