Revert "Upgrade to go 1.19 and update dependencies (#3069)" (#3085)

This reverts commit bba7c23957.
This commit is contained in:
WithoutPants
2022-11-07 12:33:15 +11:00
committed by GitHub
parent bba7c23957
commit 2609095c7a
939 changed files with 43785 additions and 101302 deletions

View File

@@ -40,18 +40,18 @@ func NewContext(app *App, set *flag.FlagSet, parentCtx *Context) *Context {
}
// NumFlags returns the number of flags set
func (cCtx *Context) NumFlags() int {
return cCtx.flagSet.NFlag()
func (c *Context) NumFlags() int {
return c.flagSet.NFlag()
}
// Set sets a context flag to a value.
func (cCtx *Context) Set(name, value string) error {
return cCtx.flagSet.Set(name, value)
func (c *Context) Set(name, value string) error {
return c.flagSet.Set(name, value)
}
// IsSet determines if the flag was actually set
func (cCtx *Context) IsSet(name string) bool {
if fs := cCtx.lookupFlagSet(name); fs != nil {
func (c *Context) IsSet(name string) bool {
if fs := c.lookupFlagSet(name); fs != nil {
isSet := false
fs.Visit(func(f *flag.Flag) {
if f.Name == name {
@@ -62,7 +62,7 @@ func (cCtx *Context) IsSet(name string) bool {
return true
}
f := cCtx.lookupFlag(name)
f := c.lookupFlag(name)
if f == nil {
return false
}
@@ -74,28 +74,28 @@ func (cCtx *Context) IsSet(name string) bool {
}
// LocalFlagNames returns a slice of flag names used in this context.
func (cCtx *Context) LocalFlagNames() []string {
func (c *Context) LocalFlagNames() []string {
var names []string
cCtx.flagSet.Visit(makeFlagNameVisitor(&names))
c.flagSet.Visit(makeFlagNameVisitor(&names))
return names
}
// FlagNames returns a slice of flag names used by the this context and all of
// its parent contexts.
func (cCtx *Context) FlagNames() []string {
func (c *Context) FlagNames() []string {
var names []string
for _, pCtx := range cCtx.Lineage() {
pCtx.flagSet.Visit(makeFlagNameVisitor(&names))
for _, ctx := range c.Lineage() {
ctx.flagSet.Visit(makeFlagNameVisitor(&names))
}
return names
}
// Lineage returns *this* context and all of its ancestor contexts in order from
// child to parent
func (cCtx *Context) Lineage() []*Context {
func (c *Context) Lineage() []*Context {
var lineage []*Context
for cur := cCtx; cur != nil; cur = cur.parentContext {
for cur := c; cur != nil; cur = cur.parentContext {
lineage = append(lineage, cur)
}
@@ -103,26 +103,26 @@ func (cCtx *Context) Lineage() []*Context {
}
// Value returns the value of the flag corresponding to `name`
func (cCtx *Context) Value(name string) interface{} {
if fs := cCtx.lookupFlagSet(name); fs != nil {
func (c *Context) Value(name string) interface{} {
if fs := c.lookupFlagSet(name); fs != nil {
return fs.Lookup(name).Value.(flag.Getter).Get()
}
return nil
}
// Args returns the command line arguments associated with the context.
func (cCtx *Context) Args() Args {
ret := args(cCtx.flagSet.Args())
func (c *Context) Args() Args {
ret := args(c.flagSet.Args())
return &ret
}
// NArg returns the number of the command line arguments.
func (cCtx *Context) NArg() int {
return cCtx.Args().Len()
func (c *Context) NArg() int {
return c.Args().Len()
}
func (cCtx *Context) lookupFlag(name string) Flag {
for _, c := range cCtx.Lineage() {
func (ctx *Context) lookupFlag(name string) Flag {
for _, c := range ctx.Lineage() {
if c.Command == nil {
continue
}
@@ -136,8 +136,8 @@ func (cCtx *Context) lookupFlag(name string) Flag {
}
}
if cCtx.App != nil {
for _, f := range cCtx.App.Flags {
if ctx.App != nil {
for _, f := range ctx.App.Flags {
for _, n := range f.Names() {
if n == name {
return f
@@ -149,8 +149,8 @@ func (cCtx *Context) lookupFlag(name string) Flag {
return nil
}
func (cCtx *Context) lookupFlagSet(name string) *flag.FlagSet {
for _, c := range cCtx.Lineage() {
func (ctx *Context) lookupFlagSet(name string) *flag.FlagSet {
for _, c := range ctx.Lineage() {
if c.flagSet == nil {
continue
}
@@ -162,7 +162,7 @@ func (cCtx *Context) lookupFlagSet(name string) *flag.FlagSet {
return nil
}
func (cCtx *Context) checkRequiredFlags(flags []Flag) requiredFlagsErr {
func (context *Context) checkRequiredFlags(flags []Flag) requiredFlagsErr {
var missingFlags []string
for _, f := range flags {
if rf, ok := f.(RequiredFlag); ok && rf.IsRequired() {
@@ -174,7 +174,7 @@ func (cCtx *Context) checkRequiredFlags(flags []Flag) requiredFlagsErr {
flagName = key
}
if cCtx.IsSet(strings.TrimSpace(key)) {
if context.IsSet(strings.TrimSpace(key)) {
flagPresent = true
}
}