From 922d2318916c3b59eafde03c36b12551a71f2d51 Mon Sep 17 00:00:00 2001 From: Lynn Cyrin Date: Thu, 11 Jul 2019 21:28:09 -0700 Subject: [PATCH] ./generate-flag-types cli -i flag-types.json -o flag_generated.go --- flag_generated.go | 78 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/flag_generated.go b/flag_generated.go index 001576c..a3e4d6e 100644 --- a/flag_generated.go +++ b/flag_generated.go @@ -14,6 +14,7 @@ type BoolFlag struct { Usage string EnvVar string FilePath string + Required bool Hidden bool Destination *bool } @@ -29,6 +30,11 @@ func (f BoolFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f BoolFlag) IsRequired() bool { + return f.Required +} + // Bool looks up the value of a local BoolFlag, returns // false if not found func (c *Context) Bool(name string) bool { @@ -62,6 +68,7 @@ type BoolTFlag struct { Usage string EnvVar string FilePath string + Required bool Hidden bool Destination *bool } @@ -77,6 +84,11 @@ func (f BoolTFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f BoolTFlag) IsRequired() bool { + return f.Required +} + // BoolT looks up the value of a local BoolTFlag, returns // false if not found func (c *Context) BoolT(name string) bool { @@ -110,6 +122,7 @@ type DurationFlag struct { Usage string EnvVar string FilePath string + Required bool Hidden bool Value time.Duration Destination *time.Duration @@ -126,6 +139,11 @@ func (f DurationFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f DurationFlag) IsRequired() bool { + return f.Required +} + // Duration looks up the value of a local DurationFlag, returns // 0 if not found func (c *Context) Duration(name string) time.Duration { @@ -159,6 +177,7 @@ type Float64Flag struct { Usage string EnvVar string FilePath string + Required bool Hidden bool Value float64 Destination *float64 @@ -175,6 +194,11 @@ func (f Float64Flag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f Float64Flag) IsRequired() bool { + return f.Required +} + // Float64 looks up the value of a local Float64Flag, returns // 0 if not found func (c *Context) Float64(name string) float64 { @@ -208,6 +232,7 @@ type GenericFlag struct { Usage string EnvVar string FilePath string + Required bool Hidden bool Value Generic } @@ -223,6 +248,11 @@ func (f GenericFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f GenericFlag) IsRequired() bool { + return f.Required +} + // Generic looks up the value of a local GenericFlag, returns // nil if not found func (c *Context) Generic(name string) interface{} { @@ -256,6 +286,7 @@ type Int64Flag struct { Usage string EnvVar string FilePath string + Required bool Hidden bool Value int64 Destination *int64 @@ -272,6 +303,11 @@ func (f Int64Flag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f Int64Flag) IsRequired() bool { + return f.Required +} + // Int64 looks up the value of a local Int64Flag, returns // 0 if not found func (c *Context) Int64(name string) int64 { @@ -305,6 +341,7 @@ type IntFlag struct { Usage string EnvVar string FilePath string + Required bool Hidden bool Value int Destination *int @@ -321,6 +358,11 @@ func (f IntFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f IntFlag) IsRequired() bool { + return f.Required +} + // Int looks up the value of a local IntFlag, returns // 0 if not found func (c *Context) Int(name string) int { @@ -354,6 +396,7 @@ type IntSliceFlag struct { Usage string EnvVar string FilePath string + Required bool Hidden bool Value *IntSlice } @@ -369,6 +412,11 @@ func (f IntSliceFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f IntSliceFlag) IsRequired() bool { + return f.Required +} + // IntSlice looks up the value of a local IntSliceFlag, returns // nil if not found func (c *Context) IntSlice(name string) []int { @@ -402,6 +450,7 @@ type Int64SliceFlag struct { Usage string EnvVar string FilePath string + Required bool Hidden bool Value *Int64Slice } @@ -417,6 +466,11 @@ func (f Int64SliceFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f Int64SliceFlag) IsRequired() bool { + return f.Required +} + // Int64Slice looks up the value of a local Int64SliceFlag, returns // nil if not found func (c *Context) Int64Slice(name string) []int64 { @@ -450,6 +504,7 @@ type StringFlag struct { Usage string EnvVar string FilePath string + Required bool Hidden bool Value string Destination *string @@ -466,6 +521,11 @@ func (f StringFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f StringFlag) IsRequired() bool { + return f.Required +} + // String looks up the value of a local StringFlag, returns // "" if not found func (c *Context) String(name string) string { @@ -499,6 +559,7 @@ type StringSliceFlag struct { Usage string EnvVar string FilePath string + Required bool Hidden bool Value *StringSlice } @@ -514,6 +575,11 @@ func (f StringSliceFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f StringSliceFlag) IsRequired() bool { + return f.Required +} + // StringSlice looks up the value of a local StringSliceFlag, returns // nil if not found func (c *Context) StringSlice(name string) []string { @@ -547,6 +613,7 @@ type Uint64Flag struct { Usage string EnvVar string FilePath string + Required bool Hidden bool Value uint64 Destination *uint64 @@ -563,6 +630,11 @@ func (f Uint64Flag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f Uint64Flag) IsRequired() bool { + return f.Required +} + // Uint64 looks up the value of a local Uint64Flag, returns // 0 if not found func (c *Context) Uint64(name string) uint64 { @@ -596,6 +668,7 @@ type UintFlag struct { Usage string EnvVar string FilePath string + Required bool Hidden bool Value uint Destination *uint @@ -612,6 +685,11 @@ func (f UintFlag) GetName() string { return f.Name } +// IsRequired returns the whether or not the flag is required +func (f UintFlag) IsRequired() bool { + return f.Required +} + // Uint looks up the value of a local UintFlag, returns // 0 if not found func (c *Context) Uint(name string) uint {