Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: urfave/cli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.23.5
Choose a base ref
...
head repository: urfave/cli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.23.6
Choose a head ref
  • 7 commits
  • 6 files changed
  • 2 contributors

Commits on Nov 16, 2022

  1. Verified

    This commit was signed with the committer’s verified signature.
    kzaher Krunoslav Zaher
    Copy the full SHA
    0f8707a View commit details
  2. Copy the full SHA
    377947f View commit details
  3. godoc

    feedmeapples committed Nov 16, 2022
    Copy the full SHA
    ceb75a1 View commit details
  4. Update godoc v2 spacing

    feedmeapples committed Nov 16, 2022
    Copy the full SHA
    9b0812c View commit details

Commits on Nov 18, 2022

  1. Merge pull request #1588 from feedmeapples/disable-slice-flag-separator

    Disable slice flag separator
    dearchap authored Nov 18, 2022
    Copy the full SHA
    5f57616 View commit details

Commits on Dec 1, 2022

  1. Copy the full SHA
    ab2bf3c View commit details

Commits on Dec 2, 2022

  1. Copy the full SHA
    f9652e3 View commit details
Showing with 34 additions and 2 deletions.
  1. +4 −0 app.go
  2. +1 −1 command.go
  3. +8 −1 flag.go
  4. +17 −0 flag_test.go
  5. +2 −0 godoc-current.txt
  6. +2 −0 testdata/godoc-v2.x.txt
4 changes: 4 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
@@ -107,6 +107,8 @@ type App struct {
CustomAppHelpTemplate string
// SliceFlagSeparator is used to customize the separator for SliceFlag, the default is ","
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
// single-character bool arguments into one
// i.e. foobar -o -v -> foobar -ov
@@ -264,6 +266,8 @@ func (a *App) Setup() {
if len(a.SliceFlagSeparator) != 0 {
defaultSliceFlagSeparator = a.SliceFlagSeparator
}

disableSliceFlagSeparator = a.DisableSliceFlagSeparator
}

func (a *App) newRootCommand() *Command {
2 changes: 1 addition & 1 deletion command.go
Original file line number Diff line number Diff line change
@@ -203,7 +203,7 @@ func (c *Command) Run(cCtx *Context, arguments ...string) (err error) {

cerr := cCtx.checkRequiredFlags(c.Flags)
if cerr != nil {
_ = ShowSubcommandHelp(cCtx)
_ = helpCommand.Action(cCtx)
return cerr
}

9 changes: 8 additions & 1 deletion flag.go
Original file line number Diff line number Diff line change
@@ -15,7 +15,10 @@ import (

const defaultPlaceholder = "value"

var defaultSliceFlagSeparator = ","
var (
defaultSliceFlagSeparator = ","
disableSliceFlagSeparator = false
)

var (
slPfx = fmt.Sprintf("sl:::%d:::", time.Now().UTC().UnixNano())
@@ -380,5 +383,9 @@ func flagFromEnvOrFile(envVars []string, filePath string) (value string, fromWhe
}

func flagSplitMultiValues(val string) []string {
if disableSliceFlagSeparator {
return []string{val}
}

return strings.Split(val, defaultSliceFlagSeparator)
}
17 changes: 17 additions & 0 deletions flag_test.go
Original file line number Diff line number Diff line change
@@ -3402,3 +3402,20 @@ func TestCustomizedSliceFlagSeparator(t *testing.T) {
}
}
}

func TestFlagSplitMultiValues_Disabled(t *testing.T) {
disableSliceFlagSeparator = true
defer func() {
disableSliceFlagSeparator = false
}()

opts := []string{"opt1", "opt2", "opt3,op", "opt4"}
ret := flagSplitMultiValues(strings.Join(opts, defaultSliceFlagSeparator))
if len(ret) != 1 {
t.Fatalf("failed to disable split slice flag, want: 1, but got: %d", len(ret))
}

if ret[0] != strings.Join(opts, defaultSliceFlagSeparator) {
t.Fatalf("failed to disable split slice flag, want: %s, but got: %s", strings.Join(opts, defaultSliceFlagSeparator), ret[0])
}
}
2 changes: 2 additions & 0 deletions godoc-current.txt
Original file line number Diff line number Diff line change
@@ -318,6 +318,8 @@ type App struct {
CustomAppHelpTemplate string
// SliceFlagSeparator is used to customize the separator for SliceFlag, the default is ","
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
// single-character bool arguments into one
// i.e. foobar -o -v -> foobar -ov
2 changes: 2 additions & 0 deletions testdata/godoc-v2.x.txt
Original file line number Diff line number Diff line change
@@ -318,6 +318,8 @@ type App struct {
CustomAppHelpTemplate string
// SliceFlagSeparator is used to customize the separator for SliceFlag, the default is ","
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
// single-character bool arguments into one
// i.e. foobar -o -v -> foobar -ov