From 82aed762725ffb7871d9d41792cbab6e17e6c7e4 Mon Sep 17 00:00:00 2001 From: Lynn Date: Wed, 25 Dec 2019 08:05:23 -0800 Subject: [PATCH 1/7] uncomment --- docs/v2/manual.md | 60 ++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/docs/v2/manual.md b/docs/v2/manual.md index b04ae02..7d93745 100644 --- a/docs/v2/manual.md +++ b/docs/v2/manual.md @@ -1402,15 +1402,13 @@ func main() { cli.ShowVersion(c) fmt.Printf("%#v\n", c.App.Command("doo")) - // // uncomment when https://github.com/urfave/cli/pull/1014 is released - // if c.Bool("infinite") { - // c.App.Run([]string{"app", "doo", "wop"}) - // } - - // // uncomment when https://github.com/urfave/cli/pull/1014 is released - // if c.Bool("forevar") { - // c.App.RunAsSubcommand(c) - // } + if c.Bool("infinite") { + c.App.Run([]string{"app", "doo", "wop"}) + } + + if c.Bool("forevar") { + c.App.RunAsSubcommand(c) + } c.App.Setup() fmt.Printf("%#v\n", c.App.VisibleCategories()) fmt.Printf("%#v\n", c.App.VisibleCommands()) @@ -1426,29 +1424,27 @@ func main() { set := flag.NewFlagSet("contrive", 0) nc := cli.NewContext(c.App, set, c) - // // uncomment when https://github.com/urfave/cli/pull/1014 is released - // fmt.Printf("%#v\n", nc.Args()) - // fmt.Printf("%#v\n", nc.Bool("nope")) - // fmt.Printf("%#v\n", !nc.Bool("nerp")) - // fmt.Printf("%#v\n", nc.Duration("howlong")) - // fmt.Printf("%#v\n", nc.Float64("hay")) - // fmt.Printf("%#v\n", nc.Generic("bloop")) - // fmt.Printf("%#v\n", nc.Int64("bonk")) - // fmt.Printf("%#v\n", nc.Int64Slice("burnks")) - // fmt.Printf("%#v\n", nc.Int("bips")) - // fmt.Printf("%#v\n", nc.IntSlice("blups")) - // fmt.Printf("%#v\n", nc.String("snurt")) - // fmt.Printf("%#v\n", nc.StringSlice("snurkles")) - // fmt.Printf("%#v\n", nc.Uint("flub")) - // fmt.Printf("%#v\n", nc.Uint64("florb")) - - // // uncomment when https://github.com/urfave/cli/pull/1014 is released - // fmt.Printf("%#v\n", nc.FlagNames()) - // fmt.Printf("%#v\n", nc.IsSet("wat")) - // fmt.Printf("%#v\n", nc.Set("wat", "nope")) - // fmt.Printf("%#v\n", nc.NArg()) - // fmt.Printf("%#v\n", nc.NumFlags()) - // fmt.Printf("%#v\n", nc.Lineage()[1]) + fmt.Printf("%#v\n", nc.Args()) + fmt.Printf("%#v\n", nc.Bool("nope")) + fmt.Printf("%#v\n", !nc.Bool("nerp")) + fmt.Printf("%#v\n", nc.Duration("howlong")) + fmt.Printf("%#v\n", nc.Float64("hay")) + fmt.Printf("%#v\n", nc.Generic("bloop")) + fmt.Printf("%#v\n", nc.Int64("bonk")) + fmt.Printf("%#v\n", nc.Int64Slice("burnks")) + fmt.Printf("%#v\n", nc.Int("bips")) + fmt.Printf("%#v\n", nc.IntSlice("blups")) + fmt.Printf("%#v\n", nc.String("snurt")) + fmt.Printf("%#v\n", nc.StringSlice("snurkles")) + fmt.Printf("%#v\n", nc.Uint("flub")) + fmt.Printf("%#v\n", nc.Uint64("florb")) + + fmt.Printf("%#v\n", nc.FlagNames()) + fmt.Printf("%#v\n", nc.IsSet("wat")) + fmt.Printf("%#v\n", nc.Set("wat", "nope")) + fmt.Printf("%#v\n", nc.NArg()) + fmt.Printf("%#v\n", nc.NumFlags()) + fmt.Printf("%#v\n", nc.Lineage()[1]) nc.Set("wat", "also-nope") ec := cli.Exit("ohwell", 86) From 62597fe929c72e20c3661d06b206a007526effb0 Mon Sep 17 00:00:00 2001 From: Dmitry Kutakov Date: Thu, 26 Dec 2019 14:05:50 +0100 Subject: [PATCH 3/7] simplify code - eliminate type assertions "gosimple" linter says: S1034: assigning the result of this type assertion to a variable (switch f := f.(type)) could eliminate the following type assertions: flag.go:267:26 flag.go:270:28 flag.go:273:30 flag.go:276:29 --- flag.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/flag.go b/flag.go index ec128fd..077a6dd 100644 --- a/flag.go +++ b/flag.go @@ -261,19 +261,19 @@ func flagValue(f Flag) reflect.Value { func stringifyFlag(f Flag) string { fv := flagValue(f) - switch f.(type) { + switch f := f.(type) { case *IntSliceFlag: return withEnvHint(flagStringSliceField(f, "EnvVars"), - stringifyIntSliceFlag(f.(*IntSliceFlag))) + stringifyIntSliceFlag(f)) case *Int64SliceFlag: return withEnvHint(flagStringSliceField(f, "EnvVars"), - stringifyInt64SliceFlag(f.(*Int64SliceFlag))) + stringifyInt64SliceFlag(f)) case *Float64SliceFlag: return withEnvHint(flagStringSliceField(f, "EnvVars"), - stringifyFloat64SliceFlag(f.(*Float64SliceFlag))) + stringifyFloat64SliceFlag(f)) case *StringSliceFlag: return withEnvHint(flagStringSliceField(f, "EnvVars"), - stringifyStringSliceFlag(f.(*StringSliceFlag))) + stringifyStringSliceFlag(f)) } placeholder, usage := unquoteUsage(fv.FieldByName("Usage").String()) From 61ac69a2782cfae5f131a1579f82590650a234ef Mon Sep 17 00:00:00 2001 From: "lynn [they]" Date: Fri, 27 Dec 2019 04:31:38 -0800 Subject: [PATCH 4/7] Update v1-bug-report.md --- .github/ISSUE_TEMPLATE/v1-bug-report.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/v1-bug-report.md b/.github/ISSUE_TEMPLATE/v1-bug-report.md index f051613..e524619 100644 --- a/.github/ISSUE_TEMPLATE/v1-bug-report.md +++ b/.github/ISSUE_TEMPLATE/v1-bug-report.md @@ -32,9 +32,13 @@ A clear and concise description of what the bug is. Describe the steps or code required to reproduce the behavior +## Observed behavior + +What did you see happen immediately after the reproduction steps above? + ## Expected behavior -A clear and concise description of what you expected to happen. +What would you have expected to happen immediately after the reproduction steps above? ## Additional context From 13f3b2949716f4a65109e53d1014e5d6d0ecf76a Mon Sep 17 00:00:00 2001 From: "lynn [they]" Date: Fri, 27 Dec 2019 04:32:02 -0800 Subject: [PATCH 5/7] Update v2-bug-report.md --- .github/ISSUE_TEMPLATE/v2-bug-report.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/v2-bug-report.md b/.github/ISSUE_TEMPLATE/v2-bug-report.md index 4d60eee..34f2350 100644 --- a/.github/ISSUE_TEMPLATE/v2-bug-report.md +++ b/.github/ISSUE_TEMPLATE/v2-bug-report.md @@ -32,9 +32,9 @@ A clear and concise description of what the bug is. Describe the steps or code required to reproduce the behavior -## Expected behavior +## Observed behavior -A clear and concise description of what you expected to happen. +What did you see happen immediately after the reproduction steps above? ## Additional context From 726724e85082a86fbe2099a8bb20832db5f2d408 Mon Sep 17 00:00:00 2001 From: "lynn [they]" Date: Fri, 27 Dec 2019 04:52:51 -0800 Subject: [PATCH 6/7] fix bad copy paste, h/t @rliebz --- .github/ISSUE_TEMPLATE/v2-bug-report.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/v2-bug-report.md b/.github/ISSUE_TEMPLATE/v2-bug-report.md index 34f2350..7412f70 100644 --- a/.github/ISSUE_TEMPLATE/v2-bug-report.md +++ b/.github/ISSUE_TEMPLATE/v2-bug-report.md @@ -28,14 +28,14 @@ _**( Put the version of urfave/cli that you are using here )**_ A clear and concise description of what the bug is. -## To reproduce - -Describe the steps or code required to reproduce the behavior - ## Observed behavior What did you see happen immediately after the reproduction steps above? +## Expected behavior + +What would you have expected to happen immediately after the reproduction steps above? + ## Additional context Add any other context about the problem here. From 31ff2100f563f23d020d8740b58f469a92887106 Mon Sep 17 00:00:00 2001 From: "lynn [they]" Date: Fri, 27 Dec 2019 04:54:31 -0800 Subject: [PATCH 7/7] fix more copy paste tragedy --- .github/ISSUE_TEMPLATE/v2-bug-report.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/v2-bug-report.md b/.github/ISSUE_TEMPLATE/v2-bug-report.md index 7412f70..8d688a9 100644 --- a/.github/ISSUE_TEMPLATE/v2-bug-report.md +++ b/.github/ISSUE_TEMPLATE/v2-bug-report.md @@ -28,6 +28,10 @@ _**( Put the version of urfave/cli that you are using here )**_ A clear and concise description of what the bug is. +## To reproduce + +Describe the steps or code required to reproduce the behavior + ## Observed behavior What did you see happen immediately after the reproduction steps above?