| 1 | package cliscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ |
| 2 | |
| 3 | import ( |
| 4 | "contextscip-go gomod github.com/golang/go/src go1.22 context/" |
| 5 | "flagscip-go gomod github.com/golang/go/src go1.22 flag/" |
| 6 | "fmtscip-go gomod github.com/golang/go/src go1.22 fmt/" |
| 7 | "reflectscip-go gomod github.com/golang/go/src go1.22 reflect/" |
| 8 | "stringsscip-go gomod github.com/golang/go/src go1.22 strings/" |
| 9 | "timescip-go gomod github.com/golang/go/src go1.22 time/" |
| 10 | ) |
| 11 | |
| 12 | // Value represents a value as used by cli. |
| 13 | // For now it implements the golang flag.Value interface |
| 14 | type Valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Value# interface { |
| 15 | flagscip-go gomod github.com/golang/go/src go1.22 flag/.Valuescip-go gomod github.com/golang/go/src go1.22 flag/Value# |
| 16 | flagscip-go gomod github.com/golang/go/src go1.22 flag/.Getterscip-go gomod github.com/golang/go/src go1.22 flag/Getter# |
| 17 | } |
| 18 | |
| 19 | type boolFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/boolFlag# interface { |
| 20 | IsBoolFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/boolFlag#IsBoolFlag.() bool |
| 21 | } |
| 22 | |
| 23 | type multiValueParsingConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/multiValueParsingConfig# struct { |
| 24 | // SliceFlagSeparator is used to customize the separator for SliceFlag, the default is "," |
| 25 | SliceFlagSeparatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/multiValueParsingConfig#SliceFlagSeparator. string |
| 26 | // DisableSliceFlagSeparator is used to disable SliceFlagSeparator, the default is false |
| 27 | DisableSliceFlagSeparatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/multiValueParsingConfig#DisableSliceFlagSeparator. bool |
| 28 | // MapFlagKeyValueSeparator is used to customize the separator for MapFlag, the default is "=" |
| 29 | MapFlagKeyValueSeparatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/multiValueParsingConfig#MapFlagKeyValueSeparator. string |
| 30 | } |
| 31 | |
| 32 | type multiValueParsingConfigSetterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/multiValueParsingConfigSetter# interface { |
| 33 | // configuration of parsing |
| 34 | setMultiValueParsingConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/multiValueParsingConfigSetter#setMultiValueParsingConfig.(c multiValueParsingConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/multiValueParsingConfig#) |
| 35 | } |
| 36 | |
| 37 | // ValueCreator is responsible for creating a flag.Value emulation |
| 38 | // as well as custom formatting |
| 39 | // |
| 40 | // T specifies the type |
| 41 | // C specifies the config for the type |
| 42 | type ValueCreatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ValueCreator#[T any, C any] interface { |
| 43 | Createscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ValueCreator#Create.(T, *T, C) Valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Value# |
| 44 | ToStringscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ValueCreator#ToString.(T) string |
| 45 | } |
| 46 | |
| 47 | // NoConfig is for flags which dont need a custom configuration |
| 48 | type NoConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/NoConfig# struct{} |
| 49 | |
| 50 | // FlagBase [T,C,VC] is a generic flag base which can be used |
| 51 | // as a boilerplate to implement the most common interfaces |
| 52 | // used by urfave/cli. |
| 53 | // |
| 54 | // T specifies the type |
| 55 | // C specifies the configuration required(if any for that flag type) |
| 56 | // VC specifies the value creator which creates the flag.Value emulation |
| 57 | type FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T any, C any, VC ValueCreatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ValueCreator#[T, C]] struct { |
| 58 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name. string `json:"name"` // name of the flag |
| 59 | Categoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Category. string `json:"category"` // category of the flag, if any |
| 60 | DefaultTextscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#DefaultText. string `json:"defaultText"` // default text of the flag for usage purposes |
| 61 | HideDefaultscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#HideDefault. bool `json:"hideDefault"` // whether to hide the default value in output |
| 62 | Usagescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Usage. string `json:"usage"` // usage string for help output |
| 63 | Sourcesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Sources. ValueSourceChainscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ValueSourceChain# `json:"-"` // sources to load flag value from |
| 64 | Requiredscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Required. bool `json:"required"` // whether the flag is required or not |
| 65 | Hiddenscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Hidden. bool `json:"hidden"` // whether to hide the flag in help output |
| 66 | Localscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Local. bool `json:"local"` // whether the flag needs to be applied to subcommands as well |
| 67 | Valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Value. T `json:"defaultValue"` // default value for this flag if not set by from any source |
| 68 | Destinationscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Destination. *T `json:"-"` // destination pointer for value when set |
| 69 | Aliasesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Aliases. []string `json:"aliases"` // Aliases that are allowed for this flag |
| 70 | TakesFilescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#TakesFile. bool `json:"takesFileArg"` // whether this flag takes a file argument, mainly for shell completion purposes |
| 71 | Actionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Action. func(contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#, T) error `json:"-"` // Action callback to be called when flag is set |
| 72 | Configscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Config. C `json:"config"` // Additional/Custom configuration associated with this flag type |
| 73 | OnlyOncescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#OnlyOnce. bool `json:"onlyOnce"` // whether this flag can be duplicated on the command line |
| 74 | Validatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Validator. func(T) error `json:"-"` // custom function to validate this flag value |
| 75 | ValidateDefaultsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#ValidateDefaults. bool `json:"validateDefaults"` // whether to validate defaults or not |
| 76 | |
| 77 | // unexported fields for internal use |
| 78 | countscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#count. int // number of times the flag has been set |
| 79 | hasBeenSetscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#hasBeenSet. bool // whether the flag has been set from env or file |
| 80 | appliedscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#applied. bool // whether the flag has been applied to a flag set already |
| 81 | creatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#creator. VC // value creator for this flag type |
| 82 | valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#value. Valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Value# // value representing this flag's value |
| 83 | } |
| 84 | |
| 85 | // GetValue returns the flags value as string representation and an empty |
| 86 | // string if the flag takes no value at all. |
| 87 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) GetValuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#GetValue().() string { |
| 88 | var v V |
| 89 | return v.ToStringscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ValueCreator#ToString.(f.Valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Value.) |
| 90 | } |
| 91 | |
| 92 | // TypeName returns the type of the flag. |
| 93 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) TypeNamescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#TypeName().() string { |
| 94 | ty := reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.TypeOfscip-go gomod github.com/golang/go/src go1.22 reflect/TypeOf().(f.Valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Value.) |
| 95 | if ty == nil { |
| 96 | return "" |
| 97 | } |
| 98 | // convert the typename to generic type |
| 99 | convertToGenericType := func(name string) string { |
| 100 | prefixMap := map[string]string{ |
| 101 | "float": "float", |
| 102 | "int": "int", |
| 103 | "uint": "uint", |
| 104 | } |
| 105 | for prefix, genericType := range prefixMap { |
| 106 | if stringsscip-go gomod github.com/golang/go/src go1.22 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.22 strings/HasPrefix().(name, prefix) { |
| 107 | return genericType |
| 108 | } |
| 109 | } |
| 110 | return stringsscip-go gomod github.com/golang/go/src go1.22 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.22 strings/ToLower().(name) |
| 111 | } |
| 112 | |
| 113 | switch ty.Kindscip-go gomod github.com/golang/go/src go1.22 reflect/Type#Kind().() { |
| 114 | // if it is a Slice, then return the slice's inner type. Will nested slices be used in the future? |
| 115 | case reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Slicescip-go gomod github.com/golang/go/src go1.22 reflect/Slice.: |
| 116 | elemType := ty.Elemscip-go gomod github.com/golang/go/src go1.22 reflect/Type#Elem().() |
| 117 | return convertToGenericType(elemType.Namescip-go gomod github.com/golang/go/src go1.22 reflect/Type#Name().()) |
| 118 | // if it is a Map, then return the map's key and value types. |
| 119 | case reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Mapscip-go gomod github.com/golang/go/src go1.22 reflect/Map.: |
| 120 | keyType := ty.Keyscip-go gomod github.com/golang/go/src go1.22 reflect/Type#Key().() |
| 121 | valueType := ty.Elemscip-go gomod github.com/golang/go/src go1.22 reflect/Type#Elem().() |
| 122 | return fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.22 fmt/Sprintf().("%s=%s", convertToGenericType(keyType.Namescip-go gomod github.com/golang/go/src go1.22 reflect/Type#Name().()), convertToGenericType(valueType.Namescip-go gomod github.com/golang/go/src go1.22 reflect/Type#Name().())) |
| 123 | default: |
| 124 | return convertToGenericType(ty.Namescip-go gomod github.com/golang/go/src go1.22 reflect/Type#Name().()) |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | // PostParse populates the flag given the flag set and environment |
| 129 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) PostParsescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#PostParse().() error { |
| 130 | tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("postparse (flag=%[1]q)", f.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.) |
| 131 | |
| 132 | if !f.hasBeenSetscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#hasBeenSet. { |
| 133 | if val, source, found := f.Sourcesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Sources..LookupWithSourcescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ValueSourceChain#LookupWithSource().(); found { |
| 134 | if val != "" || reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.TypeOfscip-go gomod github.com/golang/go/src go1.22 reflect/TypeOf().(f.Valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Value.).Kindscip-go gomod github.com/golang/go/src go1.22 reflect/Type#Kind().() == reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Stringscip-go gomod github.com/golang/go/src go1.22 reflect/String. { |
| 135 | if err := f.Setscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Set().(f.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name., val); err != nil { |
| 136 | return fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.22 fmt/Errorf().( |
| 137 | "could not parse %[1]q as %[2]T value from %[3]s for flag %[4]s: %[5]s", |
| 138 | val, f.Valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Value., source, f.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name., err, |
| 139 | ) |
| 140 | } |
| 141 | } else if val == "" && reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.TypeOfscip-go gomod github.com/golang/go/src go1.22 reflect/TypeOf().(f.Valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Value.).Kindscip-go gomod github.com/golang/go/src go1.22 reflect/Type#Kind().() == reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Boolscip-go gomod github.com/golang/go/src go1.22 reflect/Bool. { |
| 142 | _ = f.Setscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Set().(f.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name., "false") |
| 143 | } |
| 144 | |
| 145 | f.hasBeenSetscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#hasBeenSet. = true |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | return nil |
| 150 | } |
| 151 | |
| 152 | // pass configuration of parsing to value |
| 153 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) setMultiValueParsingConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#setMultiValueParsingConfig().(c multiValueParsingConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/multiValueParsingConfig#) { |
| 154 | tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("setMultiValueParsingConfig %T, %+v", f.valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#value., f.valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#value.) |
| 155 | if cf, ok := f.valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#value..(multiValueParsingConfigSetterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/multiValueParsingConfigSetter#); ok { |
| 156 | cf.setMultiValueParsingConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/multiValueParsingConfigSetter#setMultiValueParsingConfig.(c) |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) PreParsescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#PreParse().() error { |
| 161 | newVal := f.Valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Value. |
| 162 | |
| 163 | if f.Destinationscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Destination. == nil { |
| 164 | f.valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#value. = f.creatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#creator..Createscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ValueCreator#Create.(newVal, new(T), f.Configscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Config.) |
| 165 | } else { |
| 166 | f.valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#value. = f.creatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#creator..Createscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ValueCreator#Create.(newVal, f.Destinationscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Destination., f.Configscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Config.) |
| 167 | } |
| 168 | |
| 169 | // Validate the given default or values set from external sources as well |
| 170 | if f.Validatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Validator. != nil && f.ValidateDefaultsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#ValidateDefaults. { |
| 171 | if err := f.Validatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Validator.(f.valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#value..Getscip-go gomod github.com/golang/go/src go1.22 flag/Getter#Get().().(T)); err != nil { |
| 172 | return err |
| 173 | } |
| 174 | } |
| 175 | f.appliedscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#applied. = true |
| 176 | return nil |
| 177 | } |
| 178 | |
| 179 | // Set applies given value from string |
| 180 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) Setscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Set().(_ string, val string) error { |
| 181 | tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("apply (flag=%[1]q)", f.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.) |
| 182 | |
| 183 | // TODO move this phase into a separate flag initialization function |
| 184 | // if flag has been applied previously then it would have already been set |
| 185 | // from env or file. So no need to apply the env set again. However |
| 186 | // lots of units tests prior to persistent flags assumed that the |
| 187 | // flag can be applied to different flag sets multiple times while still |
| 188 | // keeping the env set. |
| 189 | if !f.appliedscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#applied. { |
| 190 | if err := f.PreParsescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#PreParse().(); err != nil { |
| 191 | return err |
| 192 | } |
| 193 | f.appliedscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#applied. = true |
| 194 | } |
| 195 | |
| 196 | if f.countscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#count. == 1 && f.OnlyOncescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#OnlyOnce. { |
| 197 | return fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.22 fmt/Errorf().("can't duplicate this flag") |
| 198 | } |
| 199 | |
| 200 | f.countscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#count.++ |
| 201 | if err := f.valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#value..Setscip-go gomod github.com/golang/go/src go1.22 flag/Value#Set().(val); err != nil { |
| 202 | return err |
| 203 | } |
| 204 | f.hasBeenSetscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#hasBeenSet. = true |
| 205 | if f.Validatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Validator. != nil { |
| 206 | if err := f.Validatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Validator.(f.valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#value..Getscip-go gomod github.com/golang/go/src go1.22 flag/Getter#Get().().(T)); err != nil { |
| 207 | return err |
| 208 | } |
| 209 | } |
| 210 | return nil |
| 211 | } |
| 212 | |
| 213 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) Getscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Get().() any { |
| 214 | if f.valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#value. != nil { |
| 215 | return f.valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#value..Getscip-go gomod github.com/golang/go/src go1.22 flag/Getter#Get().() |
| 216 | } |
| 217 | return f.Valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Value. |
| 218 | } |
| 219 | |
| 220 | // IsDefaultVisible returns true if the flag is not hidden, otherwise false |
| 221 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) IsDefaultVisiblescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#IsDefaultVisible().() bool { |
| 222 | return !f.HideDefaultscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#HideDefault. |
| 223 | } |
| 224 | |
| 225 | // String returns a readable representation of this value (for usage defaults) |
| 226 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) Stringscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#String().() string { |
| 227 | return FlagStringerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagStringer.(f) |
| 228 | } |
| 229 | |
| 230 | // IsSet returns whether or not the flag has been set through env or file |
| 231 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) IsSetscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#IsSet().() bool { |
| 232 | return f.hasBeenSetscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#hasBeenSet. |
| 233 | } |
| 234 | |
| 235 | // Names returns the names of the flag |
| 236 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Names().() []string { |
| 237 | return FlagNamesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagNames().(f.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name., f.Aliasesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Aliases.) |
| 238 | } |
| 239 | |
| 240 | // IsRequired returns whether or not the flag is required |
| 241 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) IsRequiredscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#IsRequired().() bool { |
| 242 | return f.Requiredscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Required. |
| 243 | } |
| 244 | |
| 245 | // IsVisible returns true if the flag is not hidden, otherwise false |
| 246 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) IsVisiblescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#IsVisible().() bool { |
| 247 | return !f.Hiddenscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Hidden. |
| 248 | } |
| 249 | |
| 250 | // GetCategory returns the category of the flag |
| 251 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) GetCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#GetCategory().() string { |
| 252 | return f.Categoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Category. |
| 253 | } |
| 254 | |
| 255 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) SetCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#SetCategory().(c string) { |
| 256 | f.Categoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Category. = c |
| 257 | } |
| 258 | |
| 259 | // GetUsage returns the usage string for the flag |
| 260 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) GetUsagescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#GetUsage().() string { |
| 261 | return f.Usagescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Usage. |
| 262 | } |
| 263 | |
| 264 | // GetEnvVars returns the env vars for this flag |
| 265 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) GetEnvVarsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#GetEnvVars().() []string { |
| 266 | return f.Sourcesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Sources..EnvKeysscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ValueSourceChain#EnvKeys().() |
| 267 | } |
| 268 | |
| 269 | // TakesValue returns true if the flag takes a value, otherwise false |
| 270 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) TakesValuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#TakesValue().() bool { |
| 271 | var t T |
| 272 | return reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.TypeOfscip-go gomod github.com/golang/go/src go1.22 reflect/TypeOf().(t) == nil || reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.TypeOfscip-go gomod github.com/golang/go/src go1.22 reflect/TypeOf().(t).Kindscip-go gomod github.com/golang/go/src go1.22 reflect/Type#Kind().() != reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Boolscip-go gomod github.com/golang/go/src go1.22 reflect/Bool. |
| 273 | } |
| 274 | |
| 275 | // GetDefaultText returns the default text for this flag |
| 276 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) GetDefaultTextscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#GetDefaultText().() string { |
| 277 | return f.DefaultTextscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#DefaultText. |
| 278 | } |
| 279 | |
| 280 | // RunAction executes flag action if set |
| 281 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) RunActionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#RunAction().(ctx contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) error { |
| 282 | if f.Actionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Action. != nil { |
| 283 | return f.Actionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Action.(ctx, cmd, f.valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#value..Getscip-go gomod github.com/golang/go/src go1.22 flag/Getter#Get().().(T)) |
| 284 | } |
| 285 | |
| 286 | return nil |
| 287 | } |
| 288 | |
| 289 | // SchemaType returns the JSON Schema type for the flag's value type. |
| 290 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) SchemaTypescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#SchemaType().() string { |
| 291 | var zero T |
| 292 | switch any(zero).(type) { |
| 293 | case bool: |
| 294 | return "boolean" |
| 295 | case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64: |
| 296 | return "integer" |
| 297 | case float32, float64: |
| 298 | return "number" |
| 299 | case string: |
| 300 | return "string" |
| 301 | case timescip-go gomod github.com/golang/go/src go1.22 time/.Durationscip-go gomod github.com/golang/go/src go1.22 time/Duration#: |
| 302 | return "duration" |
| 303 | case timescip-go gomod github.com/golang/go/src go1.22 time/.Timescip-go gomod github.com/golang/go/src go1.22 time/Time#: |
| 304 | return "date-time" |
| 305 | case []string, []int, []int8, []int16, []int32, []int64, |
| 306 | []uint, []uint8, []uint16, []uint32, []uint64, |
| 307 | []float32, []float64: |
| 308 | return "array" |
| 309 | case map[string]string: |
| 310 | return "object" |
| 311 | default: |
| 312 | return "" |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | // SchemaItemsType returns the JSON Schema element type for slice flags. |
| 317 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, V]) SchemaItemsTypescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#SchemaItemsType().() string { |
| 318 | var zero T |
| 319 | t := reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.TypeOfscip-go gomod github.com/golang/go/src go1.22 reflect/TypeOf().(zero) |
| 320 | if t.Kindscip-go gomod github.com/golang/go/src go1.22 reflect/Type#Kind().() == reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Slicescip-go gomod github.com/golang/go/src go1.22 reflect/Slice. { |
| 321 | switch t.Elemscip-go gomod github.com/golang/go/src go1.22 reflect/Type#Elem().().Kindscip-go gomod github.com/golang/go/src go1.22 reflect/Type#Kind().() { |
| 322 | case reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Intscip-go gomod github.com/golang/go/src go1.22 reflect/Int., reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Int8scip-go gomod github.com/golang/go/src go1.22 reflect/Int8., reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Int16scip-go gomod github.com/golang/go/src go1.22 reflect/Int16., reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Int32scip-go gomod github.com/golang/go/src go1.22 reflect/Int32., reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Int64scip-go gomod github.com/golang/go/src go1.22 reflect/Int64., |
| 323 | reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Uintscip-go gomod github.com/golang/go/src go1.22 reflect/Uint., reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Uint8scip-go gomod github.com/golang/go/src go1.22 reflect/Uint8., reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Uint16scip-go gomod github.com/golang/go/src go1.22 reflect/Uint16., reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Uint32scip-go gomod github.com/golang/go/src go1.22 reflect/Uint32., reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Uint64scip-go gomod github.com/golang/go/src go1.22 reflect/Uint64.: |
| 324 | return "integer" |
| 325 | case reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Float32scip-go gomod github.com/golang/go/src go1.22 reflect/Float32., reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Float64scip-go gomod github.com/golang/go/src go1.22 reflect/Float64.: |
| 326 | return "number" |
| 327 | case reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Stringscip-go gomod github.com/golang/go/src go1.22 reflect/String.: |
| 328 | return "string" |
| 329 | } |
| 330 | } |
| 331 | return "" |
| 332 | } |
| 333 | |
| 334 | // IsMultiValueFlag returns true if the value type T can take multiple |
| 335 | // values from cmd line. This is true for slice and map type flags |
| 336 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, VC]) IsMultiValueFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#IsMultiValueFlag().() bool { |
| 337 | // TBD how to specify |
| 338 | if reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.TypeOfscip-go gomod github.com/golang/go/src go1.22 reflect/TypeOf().(f.Valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Value.) == nil { |
| 339 | return false |
| 340 | } |
| 341 | kind := reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.TypeOfscip-go gomod github.com/golang/go/src go1.22 reflect/TypeOf().(f.Valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Value.).Kindscip-go gomod github.com/golang/go/src go1.22 reflect/Type#Kind().() |
| 342 | return kind == reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Slicescip-go gomod github.com/golang/go/src go1.22 reflect/Slice. || kind == reflectscip-go gomod github.com/golang/go/src go1.22 reflect/.Mapscip-go gomod github.com/golang/go/src go1.22 reflect/Map. |
| 343 | } |
| 344 | |
| 345 | // IsLocal returns false if flag needs to be persistent across subcommands |
| 346 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, VC]) IsLocalscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#IsLocal().() bool { |
| 347 | return f.Localscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Local. |
| 348 | } |
| 349 | |
| 350 | // IsBoolFlag returns whether the flag doesn't need to accept args |
| 351 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, VC]) IsBoolFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#IsBoolFlag().() bool { |
| 352 | bf, ok := f.valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#value..(boolFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/boolFlag#) |
| 353 | return ok && bf.IsBoolFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/boolFlag#IsBoolFlag.() |
| 354 | } |
| 355 | |
| 356 | // Count returns the number of times this flag has been invoked |
| 357 | func (f *FlagBasescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#[T, C, VC]) Countscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Count().() int { |
| 358 | return f.countscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#count. |
| 359 | } |