Skip to content

Commit

Permalink
Merge pull request #156 from akamai/release/v1.5.0
Browse files Browse the repository at this point in the history
Release/v1.5.0
  • Loading branch information
robertolopezlopez authored May 26, 2022
2 parents 67b7854 + 32079ed commit 4192214
Show file tree
Hide file tree
Showing 22 changed files with 785 additions and 319 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.5.0 (May 26, 2022)

## Enhancements

* Support for new Apple M1(Darwin ARM64) build ([GH#127](https://github.com/akamai/cli/issues/127)). NOTE: not all CLI packages currently support Apple M1.

# 1.4.2 (May 11, 2022)

## Fixes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ This command installs the CLI and persists the configuration and packages in `$H

### Compile from Source

**Prerequisite:** Make sure you install Go 1.14 or later.
**Prerequisite:** Make sure you install Go 1.17 or later.

To compile Akamai CLI from source:

Expand Down
25 changes: 13 additions & 12 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ function get_version {

get_version

mkdir -p build

GOOS=darwin GOARCH=amd64 go build -o build/akamai-$ver-macamd64 ./cli/main.go
shasum -a 256 build/akamai-$ver-macamd64 | awk '{print $1}' > build/akamai-$ver-macamd64.sig
GOOS=linux GOARCH=amd64 go build -o build/akamai-$ver-linuxamd64 ./cli/main.go
shasum -a 256 build/akamai-$ver-linuxamd64 | awk '{print $1}' > build/akamai-$ver-linuxamd64.sig
GOOS=linux GOARCH=386 go build -o build/akamai-$ver-linux386 ./cli/main.go
shasum -a 256 build/akamai-$ver-linux386 | awk '{print $1}' > build/akamai-$ver-linux386.sig
GOOS=windows GOARCH=386 go build -o build/akamai-$ver-windows386.exe ./cli/main.go
shasum -a 256 build/akamai-$ver-windows386.exe | awk '{print $1}' > build/akamai-$ver-windows386.exe.sig
GOOS=windows GOARCH=amd64 go build -o build/akamai-$ver-windowsamd64.exe ./cli/main.go
shasum -a 256 build/akamai-$ver-windowsamd64.exe | awk '{print $1}' > build/akamai-$ver-windowsamd64.exe.sig
mkdir -p build/"$ver"
GOOS=darwin GOARCH=amd64 go build -o build/"$ver"/akamai-v"$ver"-macamd64 ./cli/main.go
shasum -a 256 build/"$ver"/akamai-v"$ver"-macamd64 | awk '{print $1}' > build/"$ver"/akamai-v"$ver"-macamd64.sig
GOOS=darwin GOARCH=arm64 go build -o build/"$ver"/akamai-v"$ver"-macarm64 ./cli/main.go
shasum -a 256 build/"$ver"/akamai-v"$ver"-macarm64 | awk '{print $1}' > build/"$ver"/akamai-v"$ver"-macarm64.sig
GOOS=linux GOARCH=amd64 go build -o build/"$ver"/akamai-v"$ver"-linuxamd64 ./cli/main.go
shasum -a 256 build/"$ver"/akamai-v"$ver"-linuxamd64 | awk '{print $1}' > build/"$ver"/akamai-v"$ver"-linuxamd64.sig
GOOS=linux GOARCH=386 go build -o build/"$ver"/akamai-v"$ver"-linux386 ./cli/main.go
shasum -a 256 build/"$ver"/akamai-v"$ver"-linux386 | awk '{print $1}' > build/"$ver"/akamai-v"$ver"-linux386.sig
GOOS=windows GOARCH=386 go build -o build/"$ver"/akamai-v"$ver"-windows386.exe ./cli/main.go
shasum -a 256 build/"$ver"/akamai-v"$ver"-windows386.exe | awk '{print $1}' > build/"$ver"/akamai-v"$ver"-windows386.exe.sig
GOOS=windows GOARCH=amd64 go build -o build/"$ver"/akamai-v"$ver"-windowsamd64.exe ./cli/main.go
shasum -a 256 build/"$ver"/akamai-v"$ver"-windowsamd64.exe | awk '{print $1}' > build/"$ver"/akamai-v"$ver"-windowsamd64.exe.sig
2 changes: 1 addition & 1 deletion cli/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func Run() int {
ctx = log.SetupContext(ctx, cliApp.Writer)

cmds := commands.CommandLocator(ctx)
cliApp.Commands = cmds
cliApp.Commands = append(cmds, cliApp.Commands...)

if err := firstRun(ctx); err != nil {
return 5
Expand Down
34 changes: 28 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/akamai/cli

go 1.14
go 1.17

require (
github.com/AlecAivazis/survey/v2 v2.2.7
Expand All @@ -9,18 +9,40 @@ require (
github.com/briandowns/spinner v1.11.1
github.com/fatih/color v1.10.0
github.com/go-ini/ini v1.62.0
github.com/google/uuid v1.1.1
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/smartystreets/goconvey v1.6.4 // indirect
github.com/stretchr/testify v1.6.1
github.com/stretchr/testify v1.7.1
github.com/tj/assert v0.0.3
github.com/urfave/cli/v2 v2.3.0
golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect
golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/src-d/go-git.v4 v4.13.1
)

require (
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/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/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/pkg/errors v0.8.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/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
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
)
13 changes: 5 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
Expand All @@ -44,7 +43,6 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
Expand Down Expand Up @@ -116,8 +114,9 @@ github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tj/assert v0.0.0-20171129193455-018094318fb0/go.mod h1:mZ9/Rh9oLWpLLDRpvE+3b7gP/C2YyLFYxNmcLnPTMe0=
github.com/tj/assert v0.0.3 h1:Df/BlaZ20mq6kuai7f5z2TvPFiwC3xaWJSDQNiIS3Rk=
github.com/tj/assert v0.0.3/go.mod h1:Ne6X72Q+TB1AteidzQncjw9PabbMp4PBMZ1k+vd1Pvk=
Expand All @@ -140,9 +139,8 @@ golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand All @@ -154,7 +152,6 @@ golang.org/x/sys v0.0.0-20190530182044-ad28b68e88f1/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54 h1:rF3Ohx8DRyl8h2zw9qojyLHLhrJpEMgyPOImREEryf0=
golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -169,8 +166,8 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU=
gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.66.4 h1:SsAcf+mM7mRZo2nJNGt8mZCjG8ZRaNGMURJw7BsIST4=
gopkg.in/ini.v1 v1.66.4/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg=
gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0 h1:ivZFOIltbce2Mo8IjzUHAFoq/IylO9WHhNOAJK+LsJg=
Expand Down
153 changes: 4 additions & 149 deletions pkg/app/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import (
"strings"
"time"

"github.com/akamai/cli/pkg/apphelp"
"github.com/akamai/cli/pkg/autocomplete"
"github.com/akamai/cli/pkg/terminal"
"github.com/akamai/cli/pkg/tools"
"github.com/akamai/cli/pkg/version"

"github.com/fatih/color"
"github.com/kardianos/osext"
"github.com/mitchellh/go-homedir"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -101,7 +102,7 @@ func createAppTemplate(ctx context.Context, commandName, usage, description, ver
app.Writer = term
app.ErrWriter = term.Error()
app.EnableBashCompletion = true
app.BashComplete = DefaultAutoComplete
app.BashComplete = autocomplete.Default

var edgercpath, section string
if useDefaults {
Expand Down Expand Up @@ -147,157 +148,11 @@ func createAppTemplate(ctx context.Context, commandName, usage, description, ver
Usage: "show help",
}

SetHelpTemplates()
apphelp.Setup(app)

return app
}

// DefaultAutoComplete ...
func DefaultAutoComplete(ctx *cli.Context) {
term := terminal.Get(ctx.Context)
if ctx.Command.Name == "help" {
var args []string
args = append(args, os.Args[0])
if len(os.Args) > 2 {
args = append(args, os.Args[2:]...)
}

if err := ctx.App.Run(args); err != nil {
term.WriteError(err.Error())
}
}

commands := make([]*cli.Command, 0)
flags := make([]cli.Flag, 0)

if ctx.Command.Name == "" {
commands = ctx.App.Commands
flags = ctx.App.Flags
} else {
if len(ctx.Command.Subcommands) != 0 {
commands = ctx.Command.Subcommands
}

if len(ctx.Command.Flags) != 0 {
flags = ctx.Command.Flags
}
}

for _, command := range commands {
if command.Hidden {
continue
}

for _, name := range command.Names() {
term.Writeln(ctx.App.Writer, name)
}
}

for _, flag := range flags {
nextFlag:
for _, name := range flag.Names() {
name = strings.TrimSpace(name)

if len(cli.BashCompletionFlag.Names()) > 0 && name == cli.BashCompletionFlag.Names()[0] {
continue
}

for _, arg := range os.Args {
if arg == "--"+name || arg == "-"+name {
continue nextFlag
}
}

switch len(name) {
case 0:
case 1:
term.Writeln(ctx.App.Writer, "-"+name)
default:
term.Writeln(ctx.App.Writer, "--"+name)
}
}
}
}

// SetHelpTemplates sets up custom help outputs for app, commands and subcommands
func SetHelpTemplates() {
cli.AppHelpTemplate = "" +
color.YellowString("Usage: \n") +
color.BlueString(" {{if .UsageText}}"+
"{{.UsageText}}"+
"{{else}}"+
"{{.HelpName}} "+
"{{if .VisibleFlags}}[global flags]{{end}}"+
"{{if .Commands}} command [command flags]{{end}} "+
"{{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}"+
"\n\n{{end}}") +
"{{if .Description}}" +
color.YellowString("Description:\n") +
" {{.Description}}" +
"\n\n{{end}}" +
"{{if .VisibleCommands}}" +
color.YellowString("Built-In Commands:\n") +
"{{range .VisibleCategories}}" +
"{{if .Name}}" +
"\n{{.Name}}\n" +
"{{end}}" +
"{{range .VisibleCommands}}" +
color.GreenString(" {{.Name}}") +
"{{if .Aliases}} ({{ $length := len .Aliases }}{{if eq $length 1}}alias:{{else}}aliases:{{end}} " +
"{{range $index, $alias := .Aliases}}" +
"{{if $index}}, {{end}}" +
color.GreenString("{{$alias}}") +
"{{end}}" +
"){{end}}\n" +
"{{end}}" +
"{{end}}" +
"{{end}}\n" +
"{{if .VisibleFlags}}" +
color.YellowString("Global Flags:\n") +
"{{range $index, $option := .VisibleFlags}}" +
"{{if $index}}\n{{end}}" +
" {{$option}}" +
"{{end}}" +
"\n\n{{end}}" +
"{{if .Copyright}}" +
color.HiBlackString("{{.Copyright}}") +
"{{end}}\n"

cli.CommandHelpTemplate = "" +
color.YellowString("Name: \n") +
" {{.HelpName}}\n\n" +
color.YellowString("Usage: \n") +
color.BlueString(" {{.HelpName}}{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}\n\n") +
"{{if .Category}}" +
color.YellowString("Type: \n") +
" {{.Category}}\n\n{{end}}" +
"{{if .Description}}" +
color.YellowString("Description: \n") +
" {{.Description}}\n\n{{end}}" +
"{{if .VisibleFlags}}" +
color.YellowString("Flags: \n") +
"{{range .VisibleFlags}} {{.}}\n{{end}}{{end}}" +
"{{if .UsageText}}{{.UsageText}}\n{{end}}"

cli.SubcommandHelpTemplate = "" +
color.YellowString("Name: \n") +
" {{.HelpName}} - {{.Usage}}\n\n" +
color.YellowString("Usage: \n") +
color.BlueString(" {{.HelpName}}{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}\n\n") +
color.YellowString("Commands:\n") +
"{{range .VisibleCategories}}" +
"{{if .Name}}" +
"{{.Name}}:" +
"{{end}}" +
"{{range .VisibleCommands}}" +
`{{join .Names ", "}}{{"\t"}}{{.Usage}}` +
"{{end}}\n\n" +
"{{end}}" +
"{{if .VisibleFlags}}" +
color.YellowString("Flags:\n") +
"{{range .VisibleFlags}}{{.}}\n{{end}}{{end}}"
}

func defaultAction(c *cli.Context) error {
cmd, err := osext.Executable()
if err != nil {
Expand Down
Loading

0 comments on commit 4192214

Please sign in to comment.