update vendored libraries

This commit is contained in:
Louis Abel 2023-04-06 10:55:24 -07:00
parent 174f0860a7
commit cb5c7ea3f4
Signed by: label
GPG Key ID: 6735C0E1BD65D048
21 changed files with 288 additions and 95 deletions

2
go.mod
View File

@ -2,7 +2,7 @@ module github.com/rocky-linux/rpaste
go 1.18 go 1.18
require github.com/urfave/cli/v2 v2.23.5 require github.com/urfave/cli/v2 v2.25.1
require ( require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect

2
go.sum
View File

@ -4,5 +4,7 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/urfave/cli/v2 v2.23.5 h1:xbrU7tAYviSpqeR3X4nEFWUdB/uDZ6DE+HxmRU7Xtyw= github.com/urfave/cli/v2 v2.23.5 h1:xbrU7tAYviSpqeR3X4nEFWUdB/uDZ6DE+HxmRU7Xtyw=
github.com/urfave/cli/v2 v2.23.5/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= github.com/urfave/cli/v2 v2.23.5/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/urfave/cli/v2 v2.25.1 h1:zw8dSP7ghX0Gmm8vugrs6q9Ku0wzweqPyshy+syu9Gw=
github.com/urfave/cli/v2 v2.25.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=

View File

@ -17,10 +17,10 @@ import (
// Sane defaults and basic info // Sane defaults and basic info
var ( var (
AppName = "rpaste" AppName = "rpaste"
Version = "0.3.0" Version = "0.3.1"
DefaultConf = "/etc/rpaste/rpaste.conf" DefaultConf = "/etc/rpaste/rpaste.conf"
DefaultLexer = "text" DefaultLexer = "text"
DefaultLifeTime = "1hour" DefaultLifeTime = "1day"
// This will end up being dynamic in the future // This will end up being dynamic in the future
DefaultPasteBin = "rpaste" DefaultPasteBin = "rpaste"
DefaultSysInfo = false DefaultSysInfo = false

View File

@ -1,9 +1,9 @@
# cli # cli
[![GoDoc](https://godoc.org/github.com/urfave/cli?status.svg)](https://pkg.go.dev/github.com/urfave/cli/v2) [![Run Tests](https://github.com/urfave/cli/actions/workflows/cli.yml/badge.svg?branch=v2-maint)](https://github.com/urfave/cli/actions/workflows/cli.yml)
[![codebeat](https://codebeat.co/badges/0a8f30aa-f975-404b-b878-5fab3ae1cc5f)](https://codebeat.co/projects/github-com-urfave-cli) [![Go Reference](https://pkg.go.dev/badge/github.com/urfave/cli/v2.svg)](https://pkg.go.dev/github.com/urfave/cli/v2)
[![Go Report Card](https://goreportcard.com/badge/urfave/cli)](https://goreportcard.com/report/urfave/cli) [![Go Report Card](https://goreportcard.com/badge/github.com/urfave/cli/v2)](https://goreportcard.com/report/github.com/urfave/cli/v2)
[![codecov](https://codecov.io/gh/urfave/cli/branch/main/graph/badge.svg)](https://codecov.io/gh/urfave/cli) [![codecov](https://codecov.io/gh/urfave/cli/branch/v2-maint/graph/badge.svg?token=t9YGWLh05g)](https://app.codecov.io/gh/urfave/cli/tree/v2-maint)
cli is a simple, fast, and fun package for building command line apps in Go. The cli is a simple, fast, and fun package for building command line apps in Go. The
goal is to enable developers to write fast and distributable command line goal is to enable developers to write fast and distributable command line

View File

@ -107,6 +107,8 @@ type App struct {
CustomAppHelpTemplate string CustomAppHelpTemplate string
// SliceFlagSeparator is used to customize the separator for SliceFlag, the default is "," // SliceFlagSeparator is used to customize the separator for SliceFlag, the default is ","
SliceFlagSeparator string SliceFlagSeparator string
// DisableSliceFlagSeparator is used to disable SliceFlagSeparator, the default is false
DisableSliceFlagSeparator bool
// Boolean to enable short-option handling so user can combine several // Boolean to enable short-option handling so user can combine several
// single-character bool arguments into one // single-character bool arguments into one
// i.e. foobar -o -v -> foobar -ov // i.e. foobar -o -v -> foobar -ov
@ -119,7 +121,8 @@ type App struct {
// Treat all flags as normal arguments if true // Treat all flags as normal arguments if true
SkipFlagParsing bool SkipFlagParsing bool
didSetup bool didSetup bool
separator separatorSpec
rootCommand *Command rootCommand *Command
} }
@ -214,6 +217,16 @@ func (a *App) Setup() {
}) })
} }
if len(a.SliceFlagSeparator) != 0 {
a.separator.customized = true
a.separator.sep = a.SliceFlagSeparator
}
if a.DisableSliceFlagSeparator {
a.separator.customized = true
a.separator.disabled = true
}
var newCommands []*Command var newCommands []*Command
for _, c := range a.Commands { for _, c := range a.Commands {
@ -221,8 +234,8 @@ func (a *App) Setup() {
if c.HelpName != "" { if c.HelpName != "" {
cname = c.HelpName cname = c.HelpName
} }
c.separator = a.separator
c.HelpName = fmt.Sprintf("%s %s", a.HelpName, cname) c.HelpName = fmt.Sprintf("%s %s", a.HelpName, cname)
c.flagCategories = newFlagCategoriesFromFlags(c.Flags) c.flagCategories = newFlagCategoriesFromFlags(c.Flags)
newCommands = append(newCommands, c) newCommands = append(newCommands, c)
} }
@ -248,22 +261,11 @@ func (a *App) Setup() {
} }
sort.Sort(a.categories.(*commandCategories)) sort.Sort(a.categories.(*commandCategories))
a.flagCategories = newFlagCategories() a.flagCategories = newFlagCategoriesFromFlags(a.Flags)
for _, fl := range a.Flags {
if cf, ok := fl.(CategorizableFlag); ok {
if cf.GetCategory() != "" {
a.flagCategories.AddFlag(cf.GetCategory(), cf)
}
}
}
if a.Metadata == nil { if a.Metadata == nil {
a.Metadata = make(map[string]interface{}) a.Metadata = make(map[string]interface{})
} }
if len(a.SliceFlagSeparator) != 0 {
defaultSliceFlagSeparator = a.SliceFlagSeparator
}
} }
func (a *App) newRootCommand() *Command { func (a *App) newRootCommand() *Command {
@ -289,11 +291,12 @@ func (a *App) newRootCommand() *Command {
categories: a.categories, categories: a.categories,
SkipFlagParsing: a.SkipFlagParsing, SkipFlagParsing: a.SkipFlagParsing,
isRoot: true, isRoot: true,
separator: a.separator,
} }
} }
func (a *App) newFlagSet() (*flag.FlagSet, error) { func (a *App) newFlagSet() (*flag.FlagSet, error) {
return flagSet(a.Name, a.Flags) return flagSet(a.Name, a.Flags, a.separator)
} }
func (a *App) useShortOptionHandling() bool { func (a *App) useShortOptionHandling() bool {

View File

@ -100,10 +100,23 @@ func newFlagCategories() FlagCategories {
func newFlagCategoriesFromFlags(fs []Flag) FlagCategories { func newFlagCategoriesFromFlags(fs []Flag) FlagCategories {
fc := newFlagCategories() fc := newFlagCategories()
var categorized bool
for _, fl := range fs { for _, fl := range fs {
if cf, ok := fl.(CategorizableFlag); ok { if cf, ok := fl.(CategorizableFlag); ok {
if cf.GetCategory() != "" { if cat := cf.GetCategory(); cat != "" {
fc.AddFlag(cf.GetCategory(), cf) fc.AddFlag(cat, cf)
categorized = true
}
}
}
if categorized == true {
for _, fl := range fs {
if cf, ok := fl.(CategorizableFlag); ok {
if cf.GetCategory() == "" {
fc.AddFlag("", fl)
}
} }
} }
} }

View File

@ -69,6 +69,8 @@ type Command struct {
// if this is a root "special" command // if this is a root "special" command
isRoot bool isRoot bool
separator separatorSpec
} }
type Commands []*Command type Commands []*Command
@ -133,9 +135,14 @@ func (c *Command) setup(ctx *Context) {
if scmd.HelpName == "" { if scmd.HelpName == "" {
scmd.HelpName = fmt.Sprintf("%s %s", c.HelpName, scmd.Name) scmd.HelpName = fmt.Sprintf("%s %s", c.HelpName, scmd.Name)
} }
scmd.separator = c.separator
newCmds = append(newCmds, scmd) newCmds = append(newCmds, scmd)
} }
c.Subcommands = newCmds c.Subcommands = newCmds
if c.BashComplete == nil {
c.BashComplete = DefaultCompleteWithFlags(c)
}
} }
func (c *Command) Run(cCtx *Context, arguments ...string) (err error) { func (c *Command) Run(cCtx *Context, arguments ...string) (err error) {
@ -148,11 +155,7 @@ func (c *Command) Run(cCtx *Context, arguments ...string) (err error) {
set, err := c.parseFlags(&a, cCtx.shellComplete) set, err := c.parseFlags(&a, cCtx.shellComplete)
cCtx.flagSet = set cCtx.flagSet = set
if c.isRoot { if checkCompletions(cCtx) {
if checkCompletions(cCtx) {
return nil
}
} else if checkCommandCompletions(cCtx, c.Name) {
return nil return nil
} }
@ -203,7 +206,7 @@ func (c *Command) Run(cCtx *Context, arguments ...string) (err error) {
cerr := cCtx.checkRequiredFlags(c.Flags) cerr := cCtx.checkRequiredFlags(c.Flags)
if cerr != nil { if cerr != nil {
_ = ShowSubcommandHelp(cCtx) _ = helpCommand.Action(cCtx)
return cerr return cerr
} }
@ -275,7 +278,7 @@ func (c *Command) Run(cCtx *Context, arguments ...string) (err error) {
} }
func (c *Command) newFlagSet() (*flag.FlagSet, error) { func (c *Command) newFlagSet() (*flag.FlagSet, error) {
return flagSet(c.Name, c.Flags) return flagSet(c.Name, c.Flags, c.separator)
} }
func (c *Command) useShortOptionHandling() bool { func (c *Command) useShortOptionHandling() bool {

View File

@ -7,6 +7,8 @@ flag_types:
- name: Count - name: Count
type: int type: int
pointer: true pointer: true
- name: DisableDefaultText
type: bool
- name: Action - name: Action
type: "func(*Context, bool) error" type: "func(*Context, bool) error"
float64: float64:
@ -18,6 +20,8 @@ flag_types:
skip_interfaces: skip_interfaces:
- fmt.Stringer - fmt.Stringer
struct_fields: struct_fields:
- name: separator
type: separatorSpec
- name: Action - name: Action
type: "func(*Context, []float64) error" type: "func(*Context, []float64) error"
int: int:
@ -31,6 +35,8 @@ flag_types:
skip_interfaces: skip_interfaces:
- fmt.Stringer - fmt.Stringer
struct_fields: struct_fields:
- name: separator
type: separatorSpec
- name: Action - name: Action
type: "func(*Context, []int) error" type: "func(*Context, []int) error"
int64: int64:
@ -44,6 +50,8 @@ flag_types:
skip_interfaces: skip_interfaces:
- fmt.Stringer - fmt.Stringer
struct_fields: struct_fields:
- name: separator
type: separatorSpec
- name: Action - name: Action
type: "func(*Context, []int64) error" type: "func(*Context, []int64) error"
uint: uint:
@ -57,6 +65,8 @@ flag_types:
skip_interfaces: skip_interfaces:
- fmt.Stringer - fmt.Stringer
struct_fields: struct_fields:
- name: separator
type: separatorSpec
- name: Action - name: Action
type: "func(*Context, []uint) error" type: "func(*Context, []uint) error"
uint64: uint64:
@ -70,6 +80,8 @@ flag_types:
skip_interfaces: skip_interfaces:
- fmt.Stringer - fmt.Stringer
struct_fields: struct_fields:
- name: separator
type: separatorSpec
- name: Action - name: Action
type: "func(*Context, []uint64) error" type: "func(*Context, []uint64) error"
string: string:
@ -83,10 +95,14 @@ flag_types:
skip_interfaces: skip_interfaces:
- fmt.Stringer - fmt.Stringer
struct_fields: struct_fields:
- name: separator
type: separatorSpec
- name: TakesFile - name: TakesFile
type: bool type: bool
- name: Action - name: Action
type: "func(*Context, []string) error" type: "func(*Context, []string) error"
- name: KeepSpace
type: bool
time.Duration: time.Duration:
struct_fields: struct_fields:
- name: Action - name: Action

View File

@ -4,7 +4,7 @@ import (
"errors" "errors"
"flag" "flag"
"fmt" "fmt"
"io/ioutil" "io"
"os" "os"
"regexp" "regexp"
"runtime" "runtime"
@ -15,7 +15,10 @@ import (
const defaultPlaceholder = "value" const defaultPlaceholder = "value"
var defaultSliceFlagSeparator = "," const (
defaultSliceFlagSeparator = ","
disableSliceFlagSeparator = false
)
var ( var (
slPfx = fmt.Sprintf("sl:::%d:::", time.Now().UTC().UnixNano()) slPfx = fmt.Sprintf("sl:::%d:::", time.Now().UTC().UnixNano())
@ -31,18 +34,20 @@ var BashCompletionFlag Flag = &BoolFlag{
// VersionFlag prints the version for the application // VersionFlag prints the version for the application
var VersionFlag Flag = &BoolFlag{ var VersionFlag Flag = &BoolFlag{
Name: "version", Name: "version",
Aliases: []string{"v"}, Aliases: []string{"v"},
Usage: "print the version", Usage: "print the version",
DisableDefaultText: true,
} }
// HelpFlag prints the help for all commands and subcommands. // HelpFlag prints the help for all commands and subcommands.
// Set to nil to disable the flag. The subcommand // Set to nil to disable the flag. The subcommand
// will still be added unless HideHelp or HideHelpCommand is set to true. // will still be added unless HideHelp or HideHelpCommand is set to true.
var HelpFlag Flag = &BoolFlag{ var HelpFlag Flag = &BoolFlag{
Name: "help", Name: "help",
Aliases: []string{"h"}, Aliases: []string{"h"},
Usage: "show help", Usage: "show help",
DisableDefaultText: true,
} }
// FlagStringer converts a flag definition to a string. This is used by help // FlagStringer converts a flag definition to a string. This is used by help
@ -162,15 +167,18 @@ type Countable interface {
Count() int Count() int
} }
func flagSet(name string, flags []Flag) (*flag.FlagSet, error) { func flagSet(name string, flags []Flag, spec separatorSpec) (*flag.FlagSet, error) {
set := flag.NewFlagSet(name, flag.ContinueOnError) set := flag.NewFlagSet(name, flag.ContinueOnError)
for _, f := range flags { for _, f := range flags {
if c, ok := f.(customizedSeparator); ok {
c.WithSeparatorSpec(spec)
}
if err := f.Apply(set); err != nil { if err := f.Apply(set); err != nil {
return nil, err return nil, err
} }
} }
set.SetOutput(ioutil.Discard) set.SetOutput(io.Discard)
return set, nil return set, nil
} }
@ -334,8 +342,13 @@ func stringifyFlag(f Flag) string {
defaultValueString := "" defaultValueString := ""
if s := df.GetDefaultText(); s != "" { // set default text for all flags except bool flags
defaultValueString = fmt.Sprintf(formatDefault("%s"), s) // for bool flags display default text if DisableDefaultText is not
// set
if bf, ok := f.(*BoolFlag); !ok || !bf.DisableDefaultText {
if s := df.GetDefaultText(); s != "" {
defaultValueString = fmt.Sprintf(formatDefault("%s"), s)
}
} }
usageWithDefault := strings.TrimSpace(usage + defaultValueString) usageWithDefault := strings.TrimSpace(usage + defaultValueString)
@ -371,7 +384,7 @@ func flagFromEnvOrFile(envVars []string, filePath string) (value string, fromWhe
} }
for _, fileVar := range strings.Split(filePath, ",") { for _, fileVar := range strings.Split(filePath, ",") {
if fileVar != "" { if fileVar != "" {
if data, err := ioutil.ReadFile(fileVar); err == nil { if data, err := os.ReadFile(fileVar); err == nil {
return string(data), fmt.Sprintf("file %q", filePath), true return string(data), fmt.Sprintf("file %q", filePath), true
} }
} }
@ -379,6 +392,28 @@ func flagFromEnvOrFile(envVars []string, filePath string) (value string, fromWhe
return "", "", false return "", "", false
} }
func flagSplitMultiValues(val string) []string { type customizedSeparator interface {
return strings.Split(val, defaultSliceFlagSeparator) WithSeparatorSpec(separatorSpec)
}
type separatorSpec struct {
sep string
disabled bool
customized bool
}
func (s separatorSpec) flagSplitMultiValues(val string) []string {
var (
disabled bool = s.disabled
sep string = s.sep
)
if !s.customized {
disabled = disableSliceFlagSeparator
sep = defaultSliceFlagSeparator
}
if disabled {
return []string{val}
}
return strings.Split(val, sep)
} }

View File

@ -11,6 +11,7 @@ import (
// Float64Slice wraps []float64 to satisfy flag.Value // Float64Slice wraps []float64 to satisfy flag.Value
type Float64Slice struct { type Float64Slice struct {
slice []float64 slice []float64
separator separatorSpec
hasBeenSet bool hasBeenSet bool
} }
@ -29,6 +30,10 @@ func (f *Float64Slice) clone() *Float64Slice {
return n return n
} }
func (f *Float64Slice) WithSeparatorSpec(spec separatorSpec) {
f.separator = spec
}
// Set parses the value into a float64 and appends it to the list of values // Set parses the value into a float64 and appends it to the list of values
func (f *Float64Slice) Set(value string) error { func (f *Float64Slice) Set(value string) error {
if !f.hasBeenSet { if !f.hasBeenSet {
@ -43,7 +48,7 @@ func (f *Float64Slice) Set(value string) error {
return nil return nil
} }
for _, s := range flagSplitMultiValues(value) { for _, s := range f.separator.flagSplitMultiValues(value) {
tmp, err := strconv.ParseFloat(strings.TrimSpace(s), 64) tmp, err := strconv.ParseFloat(strings.TrimSpace(s), 64)
if err != nil { if err != nil {
return err return err
@ -148,11 +153,12 @@ func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error {
setValue = f.Value.clone() setValue = f.Value.clone()
default: default:
setValue = new(Float64Slice) setValue = new(Float64Slice)
setValue.WithSeparatorSpec(f.separator)
} }
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found { if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
if val != "" { if val != "" {
for _, s := range flagSplitMultiValues(val) { for _, s := range f.separator.flagSplitMultiValues(val) {
if err := setValue.Set(strings.TrimSpace(s)); err != nil { if err := setValue.Set(strings.TrimSpace(s)); err != nil {
return fmt.Errorf("could not parse %q as float64 slice value from %s for flag %s: %s", val, source, f.Name, err) return fmt.Errorf("could not parse %q as float64 slice value from %s for flag %s: %s", val, source, f.Name, err)
} }
@ -172,6 +178,10 @@ func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error {
return nil return nil
} }
func (f *Float64SliceFlag) WithSeparatorSpec(spec separatorSpec) {
f.separator = spec
}
// Get returns the flags value in the given Context. // Get returns the flags value in the given Context.
func (f *Float64SliceFlag) Get(ctx *Context) []float64 { func (f *Float64SliceFlag) Get(ctx *Context) []float64 {
return ctx.Float64Slice(f.Name) return ctx.Float64Slice(f.Name)

View File

@ -11,6 +11,7 @@ import (
// Int64Slice wraps []int64 to satisfy flag.Value // Int64Slice wraps []int64 to satisfy flag.Value
type Int64Slice struct { type Int64Slice struct {
slice []int64 slice []int64
separator separatorSpec
hasBeenSet bool hasBeenSet bool
} }
@ -29,6 +30,10 @@ func (i *Int64Slice) clone() *Int64Slice {
return n return n
} }
func (i *Int64Slice) WithSeparatorSpec(spec separatorSpec) {
i.separator = spec
}
// Set parses the value into an integer and appends it to the list of values // Set parses the value into an integer and appends it to the list of values
func (i *Int64Slice) Set(value string) error { func (i *Int64Slice) Set(value string) error {
if !i.hasBeenSet { if !i.hasBeenSet {
@ -43,7 +48,7 @@ func (i *Int64Slice) Set(value string) error {
return nil return nil
} }
for _, s := range flagSplitMultiValues(value) { for _, s := range i.separator.flagSplitMultiValues(value) {
tmp, err := strconv.ParseInt(strings.TrimSpace(s), 0, 64) tmp, err := strconv.ParseInt(strings.TrimSpace(s), 0, 64)
if err != nil { if err != nil {
return err return err
@ -149,10 +154,11 @@ func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error {
setValue = f.Value.clone() setValue = f.Value.clone()
default: default:
setValue = new(Int64Slice) setValue = new(Int64Slice)
setValue.WithSeparatorSpec(f.separator)
} }
if val, source, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok && val != "" { if val, source, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok && val != "" {
for _, s := range flagSplitMultiValues(val) { for _, s := range f.separator.flagSplitMultiValues(val) {
if err := setValue.Set(strings.TrimSpace(s)); err != nil { if err := setValue.Set(strings.TrimSpace(s)); err != nil {
return fmt.Errorf("could not parse %q as int64 slice value from %s for flag %s: %s", val, source, f.Name, err) return fmt.Errorf("could not parse %q as int64 slice value from %s for flag %s: %s", val, source, f.Name, err)
} }
@ -171,6 +177,10 @@ func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error {
return nil return nil
} }
func (f *Int64SliceFlag) WithSeparatorSpec(spec separatorSpec) {
f.separator = spec
}
// Get returns the flags value in the given Context. // Get returns the flags value in the given Context.
func (f *Int64SliceFlag) Get(ctx *Context) []int64 { func (f *Int64SliceFlag) Get(ctx *Context) []int64 {
return ctx.Int64Slice(f.Name) return ctx.Int64Slice(f.Name)

View File

@ -11,6 +11,7 @@ import (
// IntSlice wraps []int to satisfy flag.Value // IntSlice wraps []int to satisfy flag.Value
type IntSlice struct { type IntSlice struct {
slice []int slice []int
separator separatorSpec
hasBeenSet bool hasBeenSet bool
} }
@ -40,6 +41,10 @@ func (i *IntSlice) SetInt(value int) {
i.slice = append(i.slice, value) i.slice = append(i.slice, value)
} }
func (i *IntSlice) WithSeparatorSpec(spec separatorSpec) {
i.separator = spec
}
// Set parses the value into an integer and appends it to the list of values // Set parses the value into an integer and appends it to the list of values
func (i *IntSlice) Set(value string) error { func (i *IntSlice) Set(value string) error {
if !i.hasBeenSet { if !i.hasBeenSet {
@ -54,7 +59,7 @@ func (i *IntSlice) Set(value string) error {
return nil return nil
} }
for _, s := range flagSplitMultiValues(value) { for _, s := range i.separator.flagSplitMultiValues(value) {
tmp, err := strconv.ParseInt(strings.TrimSpace(s), 0, 64) tmp, err := strconv.ParseInt(strings.TrimSpace(s), 0, 64)
if err != nil { if err != nil {
return err return err
@ -160,10 +165,11 @@ func (f *IntSliceFlag) Apply(set *flag.FlagSet) error {
setValue = f.Value.clone() setValue = f.Value.clone()
default: default:
setValue = new(IntSlice) setValue = new(IntSlice)
setValue.WithSeparatorSpec(f.separator)
} }
if val, source, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok && val != "" { if val, source, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok && val != "" {
for _, s := range flagSplitMultiValues(val) { for _, s := range f.separator.flagSplitMultiValues(val) {
if err := setValue.Set(strings.TrimSpace(s)); err != nil { if err := setValue.Set(strings.TrimSpace(s)); err != nil {
return fmt.Errorf("could not parse %q as int slice value from %s for flag %s: %s", val, source, f.Name, err) return fmt.Errorf("could not parse %q as int slice value from %s for flag %s: %s", val, source, f.Name, err)
} }
@ -182,6 +188,10 @@ func (f *IntSliceFlag) Apply(set *flag.FlagSet) error {
return nil return nil
} }
func (f *IntSliceFlag) WithSeparatorSpec(spec separatorSpec) {
f.separator = spec
}
// Get returns the flags value in the given Context. // Get returns the flags value in the given Context.
func (f *IntSliceFlag) Get(ctx *Context) []int { func (f *IntSliceFlag) Get(ctx *Context) []int {
return ctx.IntSlice(f.Name) return ctx.IntSlice(f.Name)

View File

@ -11,7 +11,9 @@ import (
// StringSlice wraps a []string to satisfy flag.Value // StringSlice wraps a []string to satisfy flag.Value
type StringSlice struct { type StringSlice struct {
slice []string slice []string
separator separatorSpec
hasBeenSet bool hasBeenSet bool
keepSpace bool
} }
// NewStringSlice creates a *StringSlice with default values // NewStringSlice creates a *StringSlice with default values
@ -43,13 +45,20 @@ func (s *StringSlice) Set(value string) error {
return nil return nil
} }
for _, t := range flagSplitMultiValues(value) { for _, t := range s.separator.flagSplitMultiValues(value) {
s.slice = append(s.slice, strings.TrimSpace(t)) if !s.keepSpace {
t = strings.TrimSpace(t)
}
s.slice = append(s.slice, t)
} }
return nil return nil
} }
func (s *StringSlice) WithSeparatorSpec(spec separatorSpec) {
s.separator = spec
}
// String returns a readable representation of this value (for usage defaults) // String returns a readable representation of this value (for usage defaults)
func (s *StringSlice) String() string { func (s *StringSlice) String() string {
return fmt.Sprintf("%s", s.slice) return fmt.Sprintf("%s", s.slice)
@ -141,11 +150,17 @@ func (f *StringSliceFlag) Apply(set *flag.FlagSet) error {
setValue = f.Value.clone() setValue = f.Value.clone()
default: default:
setValue = new(StringSlice) setValue = new(StringSlice)
setValue.WithSeparatorSpec(f.separator)
} }
setValue.keepSpace = f.KeepSpace
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found { if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
for _, s := range flagSplitMultiValues(val) { for _, s := range f.separator.flagSplitMultiValues(val) {
if err := setValue.Set(strings.TrimSpace(s)); err != nil { if !f.KeepSpace {
s = strings.TrimSpace(s)
}
if err := setValue.Set(s); err != nil {
return fmt.Errorf("could not parse %q as string value from %s for flag %s: %s", val, source, f.Name, err) return fmt.Errorf("could not parse %q as string value from %s for flag %s: %s", val, source, f.Name, err)
} }
} }
@ -163,6 +178,10 @@ func (f *StringSliceFlag) Apply(set *flag.FlagSet) error {
return nil return nil
} }
func (f *StringSliceFlag) WithSeparatorSpec(spec separatorSpec) {
f.separator = spec
}
// Get returns the flags value in the given Context. // Get returns the flags value in the given Context.
func (f *StringSliceFlag) Get(ctx *Context) []string { func (f *StringSliceFlag) Get(ctx *Context) []string {
return ctx.StringSlice(f.Name) return ctx.StringSlice(f.Name)

View File

@ -11,6 +11,7 @@ import (
// Uint64Slice wraps []int64 to satisfy flag.Value // Uint64Slice wraps []int64 to satisfy flag.Value
type Uint64Slice struct { type Uint64Slice struct {
slice []uint64 slice []uint64
separator separatorSpec
hasBeenSet bool hasBeenSet bool
} }
@ -43,7 +44,7 @@ func (i *Uint64Slice) Set(value string) error {
return nil return nil
} }
for _, s := range flagSplitMultiValues(value) { for _, s := range i.separator.flagSplitMultiValues(value) {
tmp, err := strconv.ParseUint(strings.TrimSpace(s), 0, 64) tmp, err := strconv.ParseUint(strings.TrimSpace(s), 0, 64)
if err != nil { if err != nil {
return err return err
@ -55,6 +56,10 @@ func (i *Uint64Slice) Set(value string) error {
return nil return nil
} }
func (i *Uint64Slice) WithSeparatorSpec(spec separatorSpec) {
i.separator = spec
}
// String returns a readable representation of this value (for usage defaults) // String returns a readable representation of this value (for usage defaults)
func (i *Uint64Slice) String() string { func (i *Uint64Slice) String() string {
v := i.slice v := i.slice
@ -153,10 +158,11 @@ func (f *Uint64SliceFlag) Apply(set *flag.FlagSet) error {
setValue = f.Value.clone() setValue = f.Value.clone()
default: default:
setValue = new(Uint64Slice) setValue = new(Uint64Slice)
setValue.WithSeparatorSpec(f.separator)
} }
if val, source, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok && val != "" { if val, source, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok && val != "" {
for _, s := range flagSplitMultiValues(val) { for _, s := range f.separator.flagSplitMultiValues(val) {
if err := setValue.Set(strings.TrimSpace(s)); err != nil { if err := setValue.Set(strings.TrimSpace(s)); err != nil {
return fmt.Errorf("could not parse %q as uint64 slice value from %s for flag %s: %s", val, source, f.Name, err) return fmt.Errorf("could not parse %q as uint64 slice value from %s for flag %s: %s", val, source, f.Name, err)
} }
@ -175,6 +181,10 @@ func (f *Uint64SliceFlag) Apply(set *flag.FlagSet) error {
return nil return nil
} }
func (f *Uint64SliceFlag) WithSeparatorSpec(spec separatorSpec) {
f.separator = spec
}
// Get returns the flags value in the given Context. // Get returns the flags value in the given Context.
func (f *Uint64SliceFlag) Get(ctx *Context) []uint64 { func (f *Uint64SliceFlag) Get(ctx *Context) []uint64 {
return ctx.Uint64Slice(f.Name) return ctx.Uint64Slice(f.Name)

View File

@ -11,6 +11,7 @@ import (
// UintSlice wraps []int to satisfy flag.Value // UintSlice wraps []int to satisfy flag.Value
type UintSlice struct { type UintSlice struct {
slice []uint slice []uint
separator separatorSpec
hasBeenSet bool hasBeenSet bool
} }
@ -54,7 +55,7 @@ func (i *UintSlice) Set(value string) error {
return nil return nil
} }
for _, s := range flagSplitMultiValues(value) { for _, s := range i.separator.flagSplitMultiValues(value) {
tmp, err := strconv.ParseUint(strings.TrimSpace(s), 0, 32) tmp, err := strconv.ParseUint(strings.TrimSpace(s), 0, 32)
if err != nil { if err != nil {
return err return err
@ -66,6 +67,10 @@ func (i *UintSlice) Set(value string) error {
return nil return nil
} }
func (i *UintSlice) WithSeparatorSpec(spec separatorSpec) {
i.separator = spec
}
// String returns a readable representation of this value (for usage defaults) // String returns a readable representation of this value (for usage defaults)
func (i *UintSlice) String() string { func (i *UintSlice) String() string {
v := i.slice v := i.slice
@ -164,10 +169,11 @@ func (f *UintSliceFlag) Apply(set *flag.FlagSet) error {
setValue = f.Value.clone() setValue = f.Value.clone()
default: default:
setValue = new(UintSlice) setValue = new(UintSlice)
setValue.WithSeparatorSpec(f.separator)
} }
if val, source, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok && val != "" { if val, source, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok && val != "" {
for _, s := range flagSplitMultiValues(val) { for _, s := range f.separator.flagSplitMultiValues(val) {
if err := setValue.Set(strings.TrimSpace(s)); err != nil { if err := setValue.Set(strings.TrimSpace(s)); err != nil {
return fmt.Errorf("could not parse %q as uint slice value from %s for flag %s: %s", val, source, f.Name, err) return fmt.Errorf("could not parse %q as uint slice value from %s for flag %s: %s", val, source, f.Name, err)
} }
@ -186,6 +192,10 @@ func (f *UintSliceFlag) Apply(set *flag.FlagSet) error {
return nil return nil
} }
func (f *UintSliceFlag) WithSeparatorSpec(spec separatorSpec) {
f.separator = spec
}
// Get returns the flags value in the given Context. // Get returns the flags value in the given Context.
func (f *UintSliceFlag) Get(ctx *Context) []uint { func (f *UintSliceFlag) Get(ctx *Context) []uint {
return ctx.UintSlice(f.Name) return ctx.UintSlice(f.Name)

View File

@ -318,6 +318,8 @@ type App struct {
CustomAppHelpTemplate string CustomAppHelpTemplate string
// SliceFlagSeparator is used to customize the separator for SliceFlag, the default is "," // SliceFlagSeparator is used to customize the separator for SliceFlag, the default is ","
SliceFlagSeparator string SliceFlagSeparator string
// DisableSliceFlagSeparator is used to disable SliceFlagSeparator, the default is false
DisableSliceFlagSeparator bool
// Boolean to enable short-option handling so user can combine several // Boolean to enable short-option handling so user can combine several
// single-character bool arguments into one // single-character bool arguments into one
// i.e. foobar -o -v -> foobar -ov // i.e. foobar -o -v -> foobar -ov
@ -453,6 +455,8 @@ type BoolFlag struct {
Count *int Count *int
DisableDefaultText bool
Action func(*Context, bool) error Action func(*Context, bool) error
// Has unexported fields. // Has unexported fields.
} }
@ -879,18 +883,20 @@ var BashCompletionFlag Flag = &BoolFlag{
BashCompletionFlag enables bash-completion for all commands and subcommands BashCompletionFlag enables bash-completion for all commands and subcommands
var HelpFlag Flag = &BoolFlag{ var HelpFlag Flag = &BoolFlag{
Name: "help", Name: "help",
Aliases: []string{"h"}, Aliases: []string{"h"},
Usage: "show help", Usage: "show help",
DisableDefaultText: true,
} }
HelpFlag prints the help for all commands and subcommands. Set to nil to HelpFlag prints the help for all commands and subcommands. Set to nil to
disable the flag. The subcommand will still be added unless HideHelp or disable the flag. The subcommand will still be added unless HideHelp or
HideHelpCommand is set to true. HideHelpCommand is set to true.
var VersionFlag Flag = &BoolFlag{ var VersionFlag Flag = &BoolFlag{
Name: "version", Name: "version",
Aliases: []string{"v"}, Aliases: []string{"v"},
Usage: "print the version", Usage: "print the version",
DisableDefaultText: true,
} }
VersionFlag prints the version for the application VersionFlag prints the version for the application
@ -1032,6 +1038,8 @@ func (f *Float64Slice) String() string
func (f *Float64Slice) Value() []float64 func (f *Float64Slice) Value() []float64
Value returns the slice of float64s set by this flag Value returns the slice of float64s set by this flag
func (f *Float64Slice) WithSeparatorSpec(spec separatorSpec)
type Float64SliceFlag struct { type Float64SliceFlag struct {
Name string Name string
@ -1107,6 +1115,8 @@ func (f *Float64SliceFlag) String() string
func (f *Float64SliceFlag) TakesValue() bool func (f *Float64SliceFlag) TakesValue() bool
TakesValue returns true if the flag takes a value, otherwise false TakesValue returns true if the flag takes a value, otherwise false
func (f *Float64SliceFlag) WithSeparatorSpec(spec separatorSpec)
type Generic interface { type Generic interface {
Set(value string) error Set(value string) error
String() string String() string
@ -1273,6 +1283,8 @@ func (i *Int64Slice) String() string
func (i *Int64Slice) Value() []int64 func (i *Int64Slice) Value() []int64
Value returns the slice of ints set by this flag Value returns the slice of ints set by this flag
func (i *Int64Slice) WithSeparatorSpec(spec separatorSpec)
type Int64SliceFlag struct { type Int64SliceFlag struct {
Name string Name string
@ -1348,6 +1360,8 @@ func (f *Int64SliceFlag) String() string
func (f *Int64SliceFlag) TakesValue() bool func (f *Int64SliceFlag) TakesValue() bool
TakesValue returns true of the flag takes a value, otherwise false TakesValue returns true of the flag takes a value, otherwise false
func (f *Int64SliceFlag) WithSeparatorSpec(spec separatorSpec)
type IntFlag struct { type IntFlag struct {
Name string Name string
@ -1443,6 +1457,8 @@ func (i *IntSlice) String() string
func (i *IntSlice) Value() []int func (i *IntSlice) Value() []int
Value returns the slice of ints set by this flag Value returns the slice of ints set by this flag
func (i *IntSlice) WithSeparatorSpec(spec separatorSpec)
type IntSliceFlag struct { type IntSliceFlag struct {
Name string Name string
@ -1518,6 +1534,8 @@ func (f *IntSliceFlag) String() string
func (f *IntSliceFlag) TakesValue() bool func (f *IntSliceFlag) TakesValue() bool
TakesValue returns true of the flag takes a value, otherwise false TakesValue returns true of the flag takes a value, otherwise false
func (f *IntSliceFlag) WithSeparatorSpec(spec separatorSpec)
type InvalidFlagAccessFunc func(*Context, string) type InvalidFlagAccessFunc func(*Context, string)
InvalidFlagAccessFunc is executed when an invalid flag is accessed from the InvalidFlagAccessFunc is executed when an invalid flag is accessed from the
context. context.
@ -1786,6 +1804,8 @@ func (s *StringSlice) String() string
func (s *StringSlice) Value() []string func (s *StringSlice) Value() []string
Value returns the slice of strings set by this flag Value returns the slice of strings set by this flag
func (s *StringSlice) WithSeparatorSpec(spec separatorSpec)
type StringSliceFlag struct { type StringSliceFlag struct {
Name string Name string
@ -1807,6 +1827,8 @@ type StringSliceFlag struct {
TakesFile bool TakesFile bool
Action func(*Context, []string) error Action func(*Context, []string) error
KeepSpace bool
// Has unexported fields. // Has unexported fields.
} }
StringSliceFlag is a flag with type *StringSlice StringSliceFlag is a flag with type *StringSlice
@ -1863,6 +1885,8 @@ func (f *StringSliceFlag) String() string
func (f *StringSliceFlag) TakesValue() bool func (f *StringSliceFlag) TakesValue() bool
TakesValue returns true of the flag takes a value, otherwise false TakesValue returns true of the flag takes a value, otherwise false
func (f *StringSliceFlag) WithSeparatorSpec(spec separatorSpec)
type SuggestCommandFunc func(commands []*Command, provided string) string type SuggestCommandFunc func(commands []*Command, provided string) string
type SuggestFlagFunc func(flags []Flag, provided string, hideHelp bool) string type SuggestFlagFunc func(flags []Flag, provided string, hideHelp bool) string
@ -2057,6 +2081,8 @@ func (i *Uint64Slice) String() string
func (i *Uint64Slice) Value() []uint64 func (i *Uint64Slice) Value() []uint64
Value returns the slice of ints set by this flag Value returns the slice of ints set by this flag
func (i *Uint64Slice) WithSeparatorSpec(spec separatorSpec)
type Uint64SliceFlag struct { type Uint64SliceFlag struct {
Name string Name string
@ -2123,6 +2149,8 @@ func (f *Uint64SliceFlag) String() string
func (f *Uint64SliceFlag) TakesValue() bool func (f *Uint64SliceFlag) TakesValue() bool
TakesValue returns true of the flag takes a value, otherwise false TakesValue returns true of the flag takes a value, otherwise false
func (f *Uint64SliceFlag) WithSeparatorSpec(spec separatorSpec)
type UintFlag struct { type UintFlag struct {
Name string Name string
@ -2218,6 +2246,8 @@ func (i *UintSlice) String() string
func (i *UintSlice) Value() []uint func (i *UintSlice) Value() []uint
Value returns the slice of ints set by this flag Value returns the slice of ints set by this flag
func (i *UintSlice) WithSeparatorSpec(spec separatorSpec)
type UintSliceFlag struct { type UintSliceFlag struct {
Name string Name string
@ -2284,6 +2314,8 @@ func (f *UintSliceFlag) String() string
func (f *UintSliceFlag) TakesValue() bool func (f *UintSliceFlag) TakesValue() bool
TakesValue returns true of the flag takes a value, otherwise false TakesValue returns true of the flag takes a value, otherwise false
func (f *UintSliceFlag) WithSeparatorSpec(spec separatorSpec)
type VisibleFlag interface { type VisibleFlag interface {
Flag Flag
@ -2411,6 +2443,9 @@ func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error
Apply saves the flagSet for later usage calls, then calls the wrapped Apply saves the flagSet for later usage calls, then calls the wrapped
Float64SliceFlag.Apply Float64SliceFlag.Apply
func (f *Float64SliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error
ApplyInputSourceValue applies a Float64Slice value if required
type GenericFlag struct { type GenericFlag struct {
*cli.GenericFlag *cli.GenericFlag
// Has unexported fields. // Has unexported fields.
@ -2432,12 +2467,16 @@ type InputSourceContext interface {
Source() string Source() string
Int(name string) (int, error) Int(name string) (int, error)
Int64(name string) (int64, error)
Uint(name string) (uint, error)
Uint64(name string) (uint64, error)
Duration(name string) (time.Duration, error) Duration(name string) (time.Duration, error)
Float64(name string) (float64, error) Float64(name string) (float64, error)
String(name string) (string, error) String(name string) (string, error)
StringSlice(name string) ([]string, error) StringSlice(name string) ([]string, error)
IntSlice(name string) ([]int, error) IntSlice(name string) ([]int, error)
Int64Slice(name string) ([]int64, error) Int64Slice(name string) ([]int64, error)
Float64Slice(name string) ([]float64, error)
Generic(name string) (cli.Generic, error) Generic(name string) (cli.Generic, error)
Bool(name string) (bool, error) Bool(name string) (bool, error)
@ -2481,6 +2520,8 @@ func (f *Int64Flag) Apply(set *flag.FlagSet) error
Apply saves the flagSet for later usage calls, then calls the wrapped Apply saves the flagSet for later usage calls, then calls the wrapped
Int64Flag.Apply Int64Flag.Apply
func (f *Int64Flag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error
type Int64SliceFlag struct { type Int64SliceFlag struct {
*cli.Int64SliceFlag *cli.Int64SliceFlag
// Has unexported fields. // Has unexported fields.
@ -2551,6 +2592,10 @@ func (fsm *MapInputSource) Duration(name string) (time.Duration, error)
func (fsm *MapInputSource) Float64(name string) (float64, error) func (fsm *MapInputSource) Float64(name string) (float64, error)
Float64 returns an float64 from the map if it exists otherwise returns 0 Float64 returns an float64 from the map if it exists otherwise returns 0
func (fsm *MapInputSource) Float64Slice(name string) ([]float64, error)
Float64Slice returns an []float64 from the map if it exists otherwise
returns nil
func (fsm *MapInputSource) Generic(name string) (cli.Generic, error) func (fsm *MapInputSource) Generic(name string) (cli.Generic, error)
Generic returns an cli.Generic from the map if it exists otherwise returns Generic returns an cli.Generic from the map if it exists otherwise returns
nil nil
@ -2558,6 +2603,9 @@ func (fsm *MapInputSource) Generic(name string) (cli.Generic, error)
func (fsm *MapInputSource) Int(name string) (int, error) func (fsm *MapInputSource) Int(name string) (int, error)
Int returns an int from the map if it exists otherwise returns 0 Int returns an int from the map if it exists otherwise returns 0
func (fsm *MapInputSource) Int64(name string) (int64, error)
Int64 returns an int64 from the map if it exists otherwise returns 0
func (fsm *MapInputSource) Int64Slice(name string) ([]int64, error) func (fsm *MapInputSource) Int64Slice(name string) ([]int64, error)
Int64Slice returns an []int64 from the map if it exists otherwise returns Int64Slice returns an []int64 from the map if it exists otherwise returns
nil nil
@ -2576,6 +2624,12 @@ func (fsm *MapInputSource) StringSlice(name string) ([]string, error)
StringSlice returns an []string from the map if it exists otherwise returns StringSlice returns an []string from the map if it exists otherwise returns
nil nil
func (fsm *MapInputSource) Uint(name string) (uint, error)
Int64 returns an int64 from the map if it exists otherwise returns 0
func (fsm *MapInputSource) Uint64(name string) (uint64, error)
UInt64 returns an uint64 from the map if it exists otherwise returns 0
type PathFlag struct { type PathFlag struct {
*cli.PathFlag *cli.PathFlag
// Has unexported fields. // Has unexported fields.
@ -2641,6 +2695,8 @@ func (f *Uint64Flag) Apply(set *flag.FlagSet) error
Apply saves the flagSet for later usage calls, then calls the wrapped Apply saves the flagSet for later usage calls, then calls the wrapped
Uint64Flag.Apply Uint64Flag.Apply
func (f *Uint64Flag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error
type UintFlag struct { type UintFlag struct {
*cli.UintFlag *cli.UintFlag
// Has unexported fields. // Has unexported fields.
@ -2655,3 +2711,5 @@ func (f *UintFlag) Apply(set *flag.FlagSet) error
Apply saves the flagSet for later usage calls, then calls the wrapped Apply saves the flagSet for later usage calls, then calls the wrapped
UintFlag.Apply UintFlag.Apply
func (f *UintFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error

View File

@ -227,7 +227,7 @@ func DefaultCompleteWithFlags(cmd *Command) func(cCtx *Context) {
return return
} }
printCommandSuggestions(cCtx.App.Commands, cCtx.App.Writer) printCommandSuggestions(cCtx.Command.Subcommands, cCtx.App.Writer)
} }
} }
@ -308,15 +308,15 @@ func printVersion(cCtx *Context) {
// ShowCompletions prints the lists of commands within a given context // ShowCompletions prints the lists of commands within a given context
func ShowCompletions(cCtx *Context) { func ShowCompletions(cCtx *Context) {
a := cCtx.App c := cCtx.Command
if a != nil && a.BashComplete != nil { if c != nil && c.BashComplete != nil {
a.BashComplete(cCtx) c.BashComplete(cCtx)
} }
} }
// ShowCommandCompletions prints the custom completions for a given command // ShowCommandCompletions prints the custom completions for a given command
func ShowCommandCompletions(ctx *Context, command string) { func ShowCommandCompletions(ctx *Context, command string) {
c := ctx.App.Command(command) c := ctx.Command.Command(command)
if c != nil { if c != nil {
if c.BashComplete != nil { if c.BashComplete != nil {
c.BashComplete(ctx) c.BashComplete(ctx)
@ -453,7 +453,7 @@ func checkCompletions(cCtx *Context) bool {
if args := cCtx.Args(); args.Present() { if args := cCtx.Args(); args.Present() {
name := args.First() name := args.First()
if cmd := cCtx.App.Command(name); cmd != nil { if cmd := cCtx.Command.Command(name); cmd != nil {
// let the command handle the completion // let the command handle the completion
return false return false
} }
@ -463,15 +463,6 @@ func checkCompletions(cCtx *Context) bool {
return true return true
} }
func checkCommandCompletions(c *Context, name string) bool {
if !c.shellComplete {
return false
}
ShowCommandCompletions(c, name)
return true
}
func subtract(a, b int) int { func subtract(a, b int) int {
return a - b return a - b
} }

View File

@ -1,6 +1,3 @@
//go:build go1.18
// +build go1.18
package cli package cli
import ( import (

View File

@ -1,10 +0,0 @@
//go:build !go1.18
// +build !go1.18
package cli
import (
"flag"
)
func unwrapFlagValue(v flag.Value) flag.Value { return v }

View File

@ -25,6 +25,8 @@ type Float64SliceFlag struct {
defaultValue *Float64Slice defaultValue *Float64Slice
separator separatorSpec
Action func(*Context, []float64) error Action func(*Context, []float64) error
} }
@ -120,6 +122,8 @@ type Int64SliceFlag struct {
defaultValue *Int64Slice defaultValue *Int64Slice
separator separatorSpec
Action func(*Context, []int64) error Action func(*Context, []int64) error
} }
@ -164,6 +168,8 @@ type IntSliceFlag struct {
defaultValue *IntSlice defaultValue *IntSlice
separator separatorSpec
Action func(*Context, []int) error Action func(*Context, []int) error
} }
@ -259,9 +265,13 @@ type StringSliceFlag struct {
defaultValue *StringSlice defaultValue *StringSlice
separator separatorSpec
TakesFile bool TakesFile bool
Action func(*Context, []string) error Action func(*Context, []string) error
KeepSpace bool
} }
// IsSet returns whether or not the flag has been set through env or file // IsSet returns whether or not the flag has been set through env or file
@ -358,6 +368,8 @@ type Uint64SliceFlag struct {
defaultValue *Uint64Slice defaultValue *Uint64Slice
separator separatorSpec
Action func(*Context, []uint64) error Action func(*Context, []uint64) error
} }
@ -402,6 +414,8 @@ type UintSliceFlag struct {
defaultValue *UintSlice defaultValue *UintSlice
separator separatorSpec
Action func(*Context, []uint) error Action func(*Context, []uint) error
} }
@ -448,6 +462,8 @@ type BoolFlag struct {
Count *int Count *int
DisableDefaultText bool
Action func(*Context, bool) error Action func(*Context, bool) error
} }

2
vendor/modules.txt vendored
View File

@ -4,7 +4,7 @@ github.com/cpuguy83/go-md2man/v2/md2man
# github.com/russross/blackfriday/v2 v2.1.0 # github.com/russross/blackfriday/v2 v2.1.0
## explicit ## explicit
github.com/russross/blackfriday/v2 github.com/russross/blackfriday/v2
# github.com/urfave/cli/v2 v2.23.5 # github.com/urfave/cli/v2 v2.25.1
## explicit; go 1.18 ## explicit; go 1.18
github.com/urfave/cli/v2 github.com/urfave/cli/v2
# github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 # github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673