Questions tagged [pflag-go]

Use for questions regarding pflag-go, a drop-in replacement for flag-go, the golang package for working with command line flags.

pflag-go is a golang package for working with command line flags. It is described as a drop-in replacement for Go's flag package (), with additional capabilities for handling POSIX/GNU-style --flags.

Documentation:

3 questions
2
votes
3 answers

golang: How can I use pflag with other packages that use flag?

How does one use pflag while also using other packages that use flag? Some of these packages define flags for the flag package (e.g. in their init functions) - and require flag.Parse() to be called. Defining flags using the pflag package, require…
Ziffusion
  • 8,779
  • 4
  • 29
  • 57
1
vote
0 answers

cobra command Flag value manipulation

I want to validate my int64 flag to make sure that its not being recognised as a octal number (the value must not start with 0, if it does, I should be able to trim the leading 0 before assigning the value to the flag). This is how I create the…
ravi kumar
  • 1,548
  • 1
  • 13
  • 47
1
vote
1 answer

Casting pflags.Flag.Value as Arbitrary Types

I am using github.com/spf13/cobra to parse command-line flags and just about everything I'm doing is working well, but I'm having trouble figuring out how to get a specifically typed value out of a *cobra.Command at runtime. My command definition…
Naftuli Kay
  • 87,710
  • 93
  • 269
  • 411