From 21dfc6eb8302c4db3547a22b0843c43e36fe058e Mon Sep 17 00:00:00 2001 From: teresy Date: Wed, 10 Oct 2018 14:54:48 -0400 Subject: [PATCH 1/4] Remove redundant nil checks --- help.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/help.go b/help.go index 65874fa2fc..d4c183b3a9 100644 --- a/help.go +++ b/help.go @@ -237,10 +237,8 @@ func printHelpCustom(out io.Writer, templ string, data interface{}, customFunc m funcMap := template.FuncMap{ "join": strings.Join, } - if customFunc != nil { - for key, value := range customFunc { - funcMap[key] = value - } + for key, value := range customFunc { + funcMap[key] = value } w := tabwriter.NewWriter(out, 1, 8, 2, ' ', 0) From a0453b2200cafa97ce263a4a5df87f5087d2abda Mon Sep 17 00:00:00 2001 From: mingrammer Date: Wed, 6 Mar 2019 23:51:22 +0900 Subject: [PATCH 2/4] Fix the unaligned indents for the commands that have no categories --- app_test.go | 6 +++--- help.go | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app_test.go b/app_test.go index 629681e68b..e88b03d27c 100644 --- a/app_test.go +++ b/app_test.go @@ -136,8 +136,8 @@ func ExampleApp_Run_appHelp() { // Oliver Allen // // COMMANDS: - // describeit, d use it to see a description - // help, h Shows a list of commands or help for one command + // describeit, d use it to see a description + // help, h Shows a list of commands or help for one command // // GLOBAL OPTIONS: // --name value a name to say (default: "bob") @@ -190,7 +190,7 @@ func ExampleApp_Run_noAction() { // [global options] command [command options] [arguments...] // // COMMANDS: - // help, h Shows a list of commands or help for one command + // help, h Shows a list of commands or help for one command // // GLOBAL OPTIONS: // --help, -h show help diff --git a/help.go b/help.go index 65874fa2fc..126cc7c45f 100644 --- a/help.go +++ b/help.go @@ -30,8 +30,9 @@ AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}: COMMANDS:{{range .VisibleCategories}}{{if .Name}} - {{.Name}}:{{end}}{{range .VisibleCommands}} - {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{if .VisibleFlags}} + {{.Name}}:{{range .VisibleCommands}} + {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}} + {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{end}}{{if .VisibleFlags}} GLOBAL OPTIONS: {{range $index, $option := .VisibleFlags}}{{if $index}} @@ -71,9 +72,11 @@ USAGE: {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}} COMMANDS:{{range .VisibleCategories}}{{if .Name}} - {{.Name}}:{{end}}{{range .VisibleCommands}} - {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}} -{{end}}{{if .VisibleFlags}} + + {{.Name}}:{{range .VisibleCommands}} + {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}} + {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{if .VisibleFlags}} + OPTIONS: {{range .VisibleFlags}}{{.}} {{end}}{{end}} From ddc3453179ea450663473db4689f7c256225a72b Mon Sep 17 00:00:00 2001 From: mingrammer Date: Thu, 7 Mar 2019 00:04:18 +0900 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6eb2996558..9904334318 100644 --- a/README.md +++ b/README.md @@ -874,7 +874,7 @@ Will include: ``` COMMANDS: - noop + noop Template actions: add From 4627bbe109fb902221de0a86f20048ad5679ea0c Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Sat, 3 Aug 2019 12:55:06 +0200 Subject: [PATCH 4/4] Add go module support This adds a go.{mod,sum} file to official support go modules. Signed-off-by: Sascha Grunert --- altsrc/flag.go | 2 +- altsrc/flag_generated.go | 2 +- altsrc/flag_test.go | 2 +- altsrc/input_source_context.go | 2 +- altsrc/json_command_test.go | 2 +- altsrc/json_source_context.go | 2 +- altsrc/map_input_source.go | 2 +- altsrc/toml_command_test.go | 2 +- altsrc/toml_file_loader.go | 2 +- altsrc/yaml_command_test.go | 2 +- altsrc/yaml_file_loader.go | 2 +- go.mod | 8 ++++++++ go.sum | 6 ++++++ 13 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 go.mod create mode 100644 go.sum diff --git a/altsrc/flag.go b/altsrc/flag.go index 84ef009a5b..376733a971 100644 --- a/altsrc/flag.go +++ b/altsrc/flag.go @@ -6,7 +6,7 @@ import ( "strings" "syscall" - "gopkg.in/urfave/cli.v1" + "github.com/urfave/cli" ) // FlagInputSourceExtension is an extension interface of cli.Flag that diff --git a/altsrc/flag_generated.go b/altsrc/flag_generated.go index 0aeb0b0414..08170ca164 100644 --- a/altsrc/flag_generated.go +++ b/altsrc/flag_generated.go @@ -3,7 +3,7 @@ package altsrc import ( "flag" - "gopkg.in/urfave/cli.v1" + "github.com/urfave/cli" ) // WARNING: This file is generated! diff --git a/altsrc/flag_test.go b/altsrc/flag_test.go index cd182942d5..5f293bb6bc 100644 --- a/altsrc/flag_test.go +++ b/altsrc/flag_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "gopkg.in/urfave/cli.v1" + "github.com/urfave/cli" ) type testApplyInputSource struct { diff --git a/altsrc/input_source_context.go b/altsrc/input_source_context.go index 276dcda089..8ea7e92053 100644 --- a/altsrc/input_source_context.go +++ b/altsrc/input_source_context.go @@ -3,7 +3,7 @@ package altsrc import ( "time" - "gopkg.in/urfave/cli.v1" + "github.com/urfave/cli" ) // InputSourceContext is an interface used to allow diff --git a/altsrc/json_command_test.go b/altsrc/json_command_test.go index 1f9af36d8a..f24cae6b90 100644 --- a/altsrc/json_command_test.go +++ b/altsrc/json_command_test.go @@ -6,7 +6,7 @@ import ( "os" "testing" - "gopkg.in/urfave/cli.v1" + "github.com/urfave/cli" ) const ( diff --git a/altsrc/json_source_context.go b/altsrc/json_source_context.go index 47ce82c49b..a5b2b0d353 100644 --- a/altsrc/json_source_context.go +++ b/altsrc/json_source_context.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "gopkg.in/urfave/cli.v1" + "github.com/urfave/cli" ) // NewJSONSourceFromFlagFunc returns a func that takes a cli.Context diff --git a/altsrc/map_input_source.go b/altsrc/map_input_source.go index a111eeee28..e8cb06022f 100644 --- a/altsrc/map_input_source.go +++ b/altsrc/map_input_source.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "gopkg.in/urfave/cli.v1" + "github.com/urfave/cli" ) // MapInputSource implements InputSourceContext to return diff --git a/altsrc/toml_command_test.go b/altsrc/toml_command_test.go index a5053d4f73..1d91d56c3a 100644 --- a/altsrc/toml_command_test.go +++ b/altsrc/toml_command_test.go @@ -11,7 +11,7 @@ import ( "os" "testing" - "gopkg.in/urfave/cli.v1" + "github.com/urfave/cli" ) func TestCommandTomFileTest(t *testing.T) { diff --git a/altsrc/toml_file_loader.go b/altsrc/toml_file_loader.go index 87bb9d9161..127693aae7 100644 --- a/altsrc/toml_file_loader.go +++ b/altsrc/toml_file_loader.go @@ -10,7 +10,7 @@ import ( "reflect" "github.com/BurntSushi/toml" - "gopkg.in/urfave/cli.v1" + "github.com/urfave/cli" ) type tomlMap struct { diff --git a/altsrc/yaml_command_test.go b/altsrc/yaml_command_test.go index 9d3f431103..31f78ce589 100644 --- a/altsrc/yaml_command_test.go +++ b/altsrc/yaml_command_test.go @@ -11,7 +11,7 @@ import ( "os" "testing" - "gopkg.in/urfave/cli.v1" + "github.com/urfave/cli" ) func TestCommandYamlFileTest(t *testing.T) { diff --git a/altsrc/yaml_file_loader.go b/altsrc/yaml_file_loader.go index 202469f19a..2177c7599b 100644 --- a/altsrc/yaml_file_loader.go +++ b/altsrc/yaml_file_loader.go @@ -14,7 +14,7 @@ import ( "runtime" "strings" - "gopkg.in/urfave/cli.v1" + "github.com/urfave/cli" "gopkg.in/yaml.v2" ) diff --git a/go.mod b/go.mod new file mode 100644 index 0000000000..d5b55c460c --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module github.com/urfave/cli + +go 1.12 + +require ( + github.com/BurntSushi/toml v0.3.1 + gopkg.in/yaml.v2 v2.2.2 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000000..a2ea70251e --- /dev/null +++ b/go.sum @@ -0,0 +1,6 @@ +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=