Skip to content

Commit

Permalink
feat: modify go doc
Browse files Browse the repository at this point in the history
  • Loading branch information
FGYFFFF committed Oct 25, 2022
1 parent 2d704e8 commit c5da5f6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
27 changes: 27 additions & 0 deletions flag_test.go
Expand Up @@ -3384,3 +3384,30 @@ func TestSliceShortOptionHandle(t *testing.T) {
t.Fatal("Action callback was never called")
}
}

// Test issue #1541
func TestCustomizedSliceFlagSeparator(t *testing.T) {
opts := []string{"opt1", "opt2", "opt3,op", "opt4"}
// set args for examples sake
os.Args = []string{"multi_values",
"--stringSlice=" + strings.Join(opts, ";"),
}
app := NewApp()
app.Name = "multi_values"
app.Flags = []Flag{
&StringSliceFlag{Name: "stringSlice"},
}
app.SliceFlagSeparator = ";"
app.Action = func(ctx *Context) error {
ret := ctx.StringSlice("stringSlice")
for idx, r := range ret {
if r != opts[idx] {
t.Fatalf("get %dth failed, wanted: %s, but get: %s", idx, opts[idx], r)
}
}
return nil
}

_ = app.Run(os.Args)
defaultSliceFlagSeparator = ","
}
2 changes: 2 additions & 0 deletions godoc-current.txt
Expand Up @@ -316,6 +316,8 @@ type App struct {
// cli.go uses text/template to render templates. You can
// render custom help text by setting this variable.
CustomAppHelpTemplate string
// SliceFlagSeparator is used to customize the separator for SliceFlag, the default is ","
SliceFlagSeparator string
// Boolean to enable short-option handling so user can combine several
// single-character bool arguments into one
// i.e. foobar -o -v -> foobar -ov
Expand Down
2 changes: 2 additions & 0 deletions testdata/godoc-v2.x.txt
Expand Up @@ -316,6 +316,8 @@ type App struct {
// cli.go uses text/template to render templates. You can
// render custom help text by setting this variable.
CustomAppHelpTemplate string
// SliceFlagSeparator is used to customize the separator for SliceFlag, the default is ","
SliceFlagSeparator string
// Boolean to enable short-option handling so user can combine several
// single-character bool arguments into one
// i.e. foobar -o -v -> foobar -ov
Expand Down

0 comments on commit c5da5f6

Please sign in to comment.