Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement kingpin.boolFlag for the BoolParam #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ func (p *BoolParam) Vars() (string, string) {
return p.Name(), p.String()
}

// Set is required to set parameters from command line string
// Set is required to set parameters from command line string.
// Implements kingpin.Value
func (p *BoolParam) Set(s string) error {
v, err := strconv.ParseBool(s)
if err != nil {
Expand All @@ -442,6 +443,8 @@ func (p *BoolParam) Set(s string) error {
return nil
}

// String returns the value of this flag as text.
// Implements kingpin.Value
func (p *BoolParam) String() string {
if p.val == nil {
return "false"
Expand All @@ -459,6 +462,12 @@ func (p *BoolParam) EnvVars() (string, string) {
return p.EnvName(), p.String()
}

// IsBoolFlag marks this parameter as boolean flag
// Implements kingpin.boolFlag
func (p *BoolParam) IsBoolFlag() bool {
return true
}

type IntParam struct {
paramCommon
val *int64
Expand Down