Skip to content

chore: migrate from stdlib flag to pflag for POSIX-style double-dash …#6

Merged
krakenhavoc merged 1 commit intomainfrom
chore/pflag-migration
Apr 13, 2026
Merged

chore: migrate from stdlib flag to pflag for POSIX-style double-dash …#6
krakenhavoc merged 1 commit intomainfrom
chore/pflag-migration

Conversation

@krakenhavoc
Copy link
Copy Markdown
Contributor

This pull request updates the flag parsing library in the krakenkey CLI from the standard flag package to github.com/spf13/pflag, which is more flexible and POSIX-compliant. The main logic and behavior remain the same, but several custom flag types are updated for compatibility, and global flag handling is improved.

Dependency update:

  • Added github.com/spf13/pflag as a dependency in go.mod to replace the standard flag package.

Flag parsing migration:

  • Switched all flag parsing in cmd/krakenkey/main.go from the standard flag package to pflag, including updating the import and all usages.
  • Set SetInterspersed(false) on the global flag set to prevent interleaved flags and arguments, matching previous CLI behavior.
  • Updated the handling of the --version flag to use the new pflag API for boolean flags.

Custom flag type compatibility:

  • Added a Type() method to the stringsFlag custom flag type for pflag compatibility.
  • Added a Type() method to the triBoolFlag custom flag type for pflag compatibility.

Replace Go's standard library flag package with spf13/pflag so all subcommand flags use the conventional --double-dash syntax instead of single-dash. This aligns the CLI with POSIX/GNU conventions used by tools like gh, docker, and kubectl.

…flags

Replace Go's standard library flag package with spf13/pflag so all
subcommand flags use the conventional --double-dash syntax instead
of single-dash. This aligns the CLI with POSIX/GNU conventions used
by tools like gh, docker, and kubectl.
@krakenhavoc krakenhavoc merged commit 961550c into main Apr 13, 2026
4 checks passed
@krakenhavoc krakenhavoc deleted the chore/pflag-migration branch April 13, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant