Skip to content

Commit

Permalink
Release/v1.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
majakubiec committed Jul 28, 2022
2 parents 76bcb5c + f13d35b commit c6fc752
Show file tree
Hide file tree
Showing 37 changed files with 936 additions and 461 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
# 1.5.2 (July 28, 2022)

## Enhancements

* New help option without arguments.

## Fixes

* Fix `akamai update` command failures when the directory `~/.akamai-cli/src/cli-xyz` is in a git detached state.
* Show the correct version for CLI modules which version is set via ldflags.
* Fix execution of Python submodules on Windows ([GH#159](https://github.com/akamai/cli/issues/159)).
* Fine print update warnings for homebrew installations.
* Fix failing unit tests on Windows.

# 1.5.1 (June 8, 2022)

## Fixes

* `update` command does not work for some packages, ie. `cli-terraform`
* `update` command does not work for some packages, ie. `cli-terraform`.

# 1.5.0 (May 26, 2022)

Expand Down
33 changes: 19 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,51 @@ module github.com/akamai/cli
go 1.17

require (
github.com/AlecAivazis/survey/v2 v2.2.7
github.com/AlecAivazis/survey/v2 v2.3.5
github.com/Masterminds/semver v1.5.0
github.com/apex/log v1.9.0
github.com/briandowns/spinner v1.11.1
github.com/fatih/color v1.10.0
github.com/go-git/go-git/v5 v5.4.2
github.com/go-ini/ini v1.62.0
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
github.com/mattn/go-colorable v0.1.8
github.com/mattn/go-isatty v0.0.12
github.com/mitchellh/go-homedir v1.1.0
github.com/stretchr/testify v1.7.1
github.com/stretchr/testify v1.8.0
github.com/tj/assert v0.0.3
github.com/urfave/cli/v2 v2.3.0
golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54
gopkg.in/src-d/go-git.v4 v4.13.1
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150
)

require (
github.com/Microsoft/go-winio v0.4.16 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect
github.com/acomagu/bufpipe v1.0.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.3.1 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/sergi/go-diff v1.0.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/src-d/gcfg v1.4.0 // indirect
github.com/stretchr/objx v0.2.0 // indirect
github.com/xanzy/ssh-agent v0.2.1 // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 // indirect
github.com/stretchr/objx v0.4.0 // indirect
github.com/xanzy/ssh-agent v0.3.0 // indirect
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 // indirect
golang.org/x/text v0.3.3 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
133 changes: 82 additions & 51 deletions go.sum

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions pkg/apphelp/help_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,19 @@ func isBuiltinCommand(c *cli.Context, cmdName string) bool {
if cmd.Name == cmdName {
return true
}
if contains(cmd.Aliases, cmdName) {
return true
}
}

return false
}

func contains(slc []string, e string) bool {
for _, s := range slc {
if s == e {
return true
}
}
return false
}
183 changes: 164 additions & 19 deletions pkg/apphelp/help_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"runtime"
"strings"

"os"
Expand All @@ -17,6 +18,10 @@ import (
)

func TestCmdHelp(t *testing.T) {
var binarySuffix string
if runtime.GOOS == "windows" {
binarySuffix = ".exe"
}
tests := map[string]struct {
args []string
cmd *cli.Command
Expand All @@ -29,9 +34,9 @@ func TestCmdHelp(t *testing.T) {
Description: "test command",
Category: "",
},
expectedOutput: `
expectedOutput: fmt.Sprintf(`
Usage:
apphelp.test [global flags] command [command flags] [arguments...]
apphelp.test%s [global flags] command [command flags] [arguments...]
Commands:
help
Expand All @@ -40,7 +45,7 @@ Commands:
Global Flags:
--edgerc value, -e value edgerc config path passed to executed commands, defaults to ~/.edgerc
--section value, -s value edgerc section name passed to executed commands, defaults to 'default'
--help, -h show help (default: false)`,
--help, -h show help (default: false)`, binarySuffix),
},

"help for specific command": {
Expand All @@ -57,12 +62,12 @@ Global Flags:
},
},
},
expectedOutput: `
expectedOutput: fmt.Sprintf(`
Name:
apphelp.test test
apphelp.test%s test
Usage:
apphelp.test [global flags] test [command flags] <arg1> <arg2>
apphelp.test%s [global flags] test [command flags] <arg1> <arg2>
Description:
test command
Expand All @@ -74,7 +79,41 @@ Command Flags:
Global Flags:
--edgerc value, -e value edgerc config path passed to executed commands, defaults to ~/.edgerc
--section value, -s value edgerc section name passed to executed commands, defaults to 'default'
`,
`, binarySuffix, binarySuffix),
},
"help for specific command alias": {
args: []string{"test-alias"},
cmd: &cli.Command{
Name: "test",
Aliases: []string{"test-alias"},
Description: "test command",
Category: "",
ArgsUsage: "<arg1> <arg2>",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "test-flag",
Usage: "this is a test flag",
},
},
},
expectedOutput: fmt.Sprintf(`
Name:
apphelp.test%s test
Usage:
apphelp.test%s [global flags] test [command flags] <arg1> <arg2>
Description:
test command
Command Flags:
--test-flag this is a test flag (default: false)
--help, -h show help (default: false)
Global Flags:
--edgerc value, -e value edgerc config path passed to executed commands, defaults to ~/.edgerc
--section value, -s value edgerc section name passed to executed commands, defaults to 'default'
`, binarySuffix, binarySuffix),
},

"help for a subcommand": {
Expand All @@ -97,12 +136,12 @@ Global Flags:
},
},
},
expectedOutput: `
expectedOutput: fmt.Sprintf(`
Name:
apphelp.test test subcommand
apphelp.test%s test subcommand
Usage:
apphelp.test [global flags] test subcommand [command flags] [arguments...]
apphelp.test%s [global flags] test subcommand [command flags]
Description:
a test subcommand without a category
Expand All @@ -114,7 +153,7 @@ Command Flags:
Global Flags:
--edgerc value, -e value edgerc config path passed to executed commands, defaults to ~/.edgerc
--section value, -s value edgerc section name passed to executed commands, defaults to 'default'
`,
`, binarySuffix, binarySuffix),
},

"help for command with subcommands": {
Expand Down Expand Up @@ -146,12 +185,15 @@ Global Flags:
},
},
},
expectedOutput: `
expectedOutput: fmt.Sprintf(`
Name:
apphelp.test test - A new cli application
apphelp.test%s test
Usage:
apphelp.test [global flags] test [command flags] <subcommand> [arguments...]
apphelp.test%s [global flags] test [command flags] <subcommand>
Description:
test command
Subcommands:
subcommand-no-category
Expand All @@ -168,7 +210,106 @@ Command Flags:
Global Flags:
--edgerc value, -e value edgerc config path passed to executed commands, defaults to ~/.edgerc
--section value, -s value edgerc section name passed to executed commands, defaults to 'default'
`,
`, binarySuffix, binarySuffix),
},

"help for subcommand no category": {
args: []string{"test", "subcommand-no-category"},
cmd: &cli.Command{
Name: "test",
Description: "test command",
Category: "",
Action: func(ctx *cli.Context) error { fmt.Println("oops!"); return nil },
Subcommands: []*cli.Command{
{
Name: "subcommand-no-category",
Description: "a test subcommand without a category",
},
{
Name: "subcommand-with-aliases",
Description: "a test subcommand with aliases and without a category",
Aliases: []string{"sub-wa", "s-w-a"},
},
{
Name: "subcommand-in-category1",
Description: "a test subcommand in category 1",
Category: "category1",
},
{
Name: "subcommand-in-category2",
Description: "a test subcommand in category 2",
Category: "category2",
},
},
},
expectedOutput: fmt.Sprintf(`
Name:
apphelp.test%s test subcommand-no-category
Usage:
apphelp.test%s [global flags] test subcommand-no-category [command flags]
Description:
a test subcommand without a category
Command Flags:
--help, -h show help (default: false)
Global Flags:
--edgerc value, -e value edgerc config path passed to executed commands, defaults to ~/.edgerc
--section value, -s value edgerc section name passed to executed commands, defaults to 'default'
`, binarySuffix, binarySuffix),
},

"help for subcommands with category": {
args: []string{"test", "subcommand-in-category1"},
cmd: &cli.Command{
Name: "test",
Description: "test command",
Category: "",
Action: func(ctx *cli.Context) error { fmt.Println("oops!"); return nil },
Subcommands: []*cli.Command{
{
Name: "subcommand-no-category",
Description: "a test subcommand without a category",
},
{
Name: "subcommand-with-aliases",
Description: "a test subcommand with aliases and without a category",
Aliases: []string{"sub-wa", "s-w-a"},
},
{
Name: "subcommand-in-category1",
Description: "a test subcommand in category 1",
Category: "category1",
},
{
Name: "subcommand-in-category2",
Description: "a test subcommand in category 2",
Category: "category2",
},
},
},
expectedOutput: fmt.Sprintf(`
Name:
apphelp.test%s test subcommand-in-category1
Usage:
apphelp.test%s [global flags] test subcommand-in-category1 [command flags]
Type:
category1
Description:
a test subcommand in category 1
Command Flags:
--help, -h show help (default: false)
Global Flags:
--edgerc value, -e value edgerc config path passed to executed commands, defaults to ~/.edgerc
--section value, -s value edgerc section name passed to executed commands, defaults to 'default'
`, binarySuffix, binarySuffix),
},

"help for command with simplified template": {
Expand All @@ -186,20 +327,20 @@ Global Flags:
},
CustomHelpTemplate: SimplifiedHelpTemplate,
},
expectedOutput: `
expectedOutput: fmt.Sprintf(`
Name:
apphelp.test test
apphelp.test%s test
Usage:
apphelp.test test [command flags]
apphelp.test%s test [command flags]
Description:
test command
Command Flags:
--test-flag this is a test flag (default: false)
--help, -h show help (default: false)
`,
`, binarySuffix, binarySuffix),
},
}

Expand Down Expand Up @@ -240,3 +381,7 @@ Command Flags:
}
}
}

//func TestIsBuiltinCommand(t *testing.T) {
//
//}
Loading

0 comments on commit c6fc752

Please sign in to comment.