mirror of
https://github.com/vbatts/go-mtree.git
synced 2025-06-05 02:42:27 +00:00
go: updating modules
It seems this may be the last update to urfave/cli for go1.17, as their v2.25 uses generics of go1.18 and didn't partition it with build tags 😵😵😵 Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
c6a7295705
commit
45591ed121
40 changed files with 2475 additions and 731 deletions
38
vendor/github.com/urfave/cli/v2/flag_generic.go
generated
vendored
38
vendor/github.com/urfave/cli/v2/flag_generic.go
generated
vendored
|
@ -11,6 +11,19 @@ type Generic interface {
|
|||
String() string
|
||||
}
|
||||
|
||||
type stringGeneric struct {
|
||||
value string
|
||||
}
|
||||
|
||||
func (s *stringGeneric) Set(value string) error {
|
||||
s.value = value
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *stringGeneric) String() string {
|
||||
return s.value
|
||||
}
|
||||
|
||||
// TakesValue returns true of the flag takes a value, otherwise false
|
||||
func (f *GenericFlag) TakesValue() bool {
|
||||
return true
|
||||
|
@ -40,7 +53,10 @@ func (f *GenericFlag) GetDefaultText() string {
|
|||
if f.DefaultText != "" {
|
||||
return f.DefaultText
|
||||
}
|
||||
return f.GetValue()
|
||||
if f.defaultValue != nil {
|
||||
return f.defaultValue.String()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetEnvVars returns the env vars for this flag
|
||||
|
@ -50,7 +66,12 @@ func (f *GenericFlag) GetEnvVars() []string {
|
|||
|
||||
// Apply takes the flagset and calls Set on the generic flag with the value
|
||||
// provided by the user for parsing by the flag
|
||||
func (f GenericFlag) Apply(set *flag.FlagSet) error {
|
||||
func (f *GenericFlag) Apply(set *flag.FlagSet) error {
|
||||
// set default value so that environment wont be able to overwrite it
|
||||
if f.Value != nil {
|
||||
f.defaultValue = &stringGeneric{value: f.Value.String()}
|
||||
}
|
||||
|
||||
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
||||
if val != "" {
|
||||
if err := f.Value.Set(val); err != nil {
|
||||
|
@ -62,6 +83,10 @@ func (f GenericFlag) Apply(set *flag.FlagSet) error {
|
|||
}
|
||||
|
||||
for _, name := range f.Names() {
|
||||
if f.Destination != nil {
|
||||
set.Var(f.Destination, name, f.Usage)
|
||||
continue
|
||||
}
|
||||
set.Var(f.Value, name, f.Usage)
|
||||
}
|
||||
|
||||
|
@ -73,6 +98,15 @@ func (f *GenericFlag) Get(ctx *Context) interface{} {
|
|||
return ctx.Generic(f.Name)
|
||||
}
|
||||
|
||||
// RunAction executes flag action if set
|
||||
func (f *GenericFlag) RunAction(c *Context) error {
|
||||
if f.Action != nil {
|
||||
return f.Action(c, c.Generic(f.Name))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Generic looks up the value of a local GenericFlag, returns
|
||||
// nil if not found
|
||||
func (cCtx *Context) Generic(name string) interface{} {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue