flags : generic string|bool value field
This commit is contained in:
parent
f23a98fb5d
commit
d89b48adc3
3 changed files with 12 additions and 14 deletions
|
|
@ -10,18 +10,16 @@ type Arg struct {
|
|||
Help string
|
||||
}
|
||||
|
||||
type Flag struct {
|
||||
Long string
|
||||
Short string
|
||||
Val string
|
||||
Help string
|
||||
// type constraint
|
||||
type Val interface {
|
||||
string | bool
|
||||
}
|
||||
|
||||
// there's got to be a way to generalize the val field to string|bool
|
||||
type FlagBool struct {
|
||||
// with generic Val field, instantiate like Flag[string]
|
||||
type Flag[V Val] struct {
|
||||
Long string
|
||||
Short string
|
||||
Val bool
|
||||
Val V
|
||||
Help string
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue