From c3c670b954afd88fe8b73e4951594325fd92612c Mon Sep 17 00:00:00 2001 From: "Soren L. Hansen" Date: Sun, 18 Apr 2021 07:01:31 -0700 Subject: [PATCH] Switch to urfave/cli/v2... again. --- go.mod | 10 +++++----- go.sum | 2 ++ help.go | 19 ------------------- main.go | 5 ++--- utils/flags.go | 6 +++++- 5 files changed, 14 insertions(+), 28 deletions(-) delete mode 100644 help.go diff --git a/go.mod b/go.mod index e2d2c27..86fa20a 100644 --- a/go.mod +++ b/go.mod @@ -4,13 +4,13 @@ go 1.13 require ( github.com/NYTimes/gziphandler v1.1.1 - github.com/creack/pty v1.1.7 - github.com/elazarl/go-bindata-assetfs v1.0.0 + github.com/creack/pty v1.1.11 + github.com/elazarl/go-bindata-assetfs v1.0.1 github.com/fatih/structs v1.1.0 - github.com/gorilla/websocket v1.4.1 - github.com/hashicorp/go-multierror v1.0.0 // indirect + github.com/gorilla/websocket v1.4.2 + github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/pkg/errors v0.9.1 github.com/urfave/cli/v2 v2.3.0 github.com/yudai/hcl v0.0.0-20151013225006-5fa2393b3552 - golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae // indirect + golang.org/x/sys v0.0.0-20210415045647-66c3f260301c // indirect ) diff --git a/go.sum b/go.sum index 0dd64b1..57f1be3 100644 --- a/go.sum +++ b/go.sum @@ -44,6 +44,8 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepx golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210412220455-f1c623a9e750 h1:ZBu6861dZq7xBnG1bn5SRU0vA8nx42at4+kP07FMTog= golang.org/x/sys v0.0.0-20210412220455-f1c623a9e750/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210415045647-66c3f260301c h1:6L+uOeS3OQt/f4eFHXZcTxeZrGCuz+CLElgEBjbcTA4= +golang.org/x/sys v0.0.0-20210415045647-66c3f260301c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/help.go b/help.go deleted file mode 100644 index edda2fc..0000000 --- a/help.go +++ /dev/null @@ -1,19 +0,0 @@ -package main - -var helpTemplate = `NAME: - {{.Name}} - {{.Usage}} - -USAGE: - {{.Name}} [options] [] - -VERSION: - {{.Version}}{{if or .Author .Email}} - -AUTHOR:{{if .Author}} - {{.Author}}{{if .Email}} - <{{.Email}}>{{end}}{{else}} - {{.Email}}{{end}}{{end}} - -OPTIONS: - {{range .Flags}}{{.}} - {{end}} -` diff --git a/main.go b/main.go index 456eda6..4bf1ee7 100644 --- a/main.go +++ b/main.go @@ -22,10 +22,9 @@ func main() { app.Name = "gotty" app.Version = Version + "+" + CommitID app.Usage = "Share your terminal as a web application" - app.HideHelp = true - cli.AppHelpTemplate = helpTemplate - + app.HideHelpCommand = true appOptions := &server.Options{} + if err := utils.ApplyDefaultValues(appOptions); err != nil { exit(err, 1) } diff --git a/utils/flags.go b/utils/flags.go index 078e444..dc24783 100644 --- a/utils/flags.go +++ b/utils/flags.go @@ -28,8 +28,9 @@ func GenerateFlags(options ...interface{}) (flags []cli.Flag, mappings map[strin mappings[flagName] = field.Name() flagShortName := field.Tag("flagSName") + var aliases []string if flagShortName != "" { - flagName += ", " + flagShortName + aliases = []string{flagShortName} } flagDescription := field.Tag("flagDescribe") @@ -41,12 +42,14 @@ func GenerateFlags(options ...interface{}) (flags []cli.Flag, mappings map[strin Value: field.Value().(string), Usage: flagDescription, EnvVars: []string{envName}, + Aliases: aliases, }) case reflect.Bool: flags = append(flags, &cli.BoolFlag{ Name: flagName, Usage: flagDescription, EnvVars: []string{envName}, + Aliases: aliases, }) case reflect.Int: flags = append(flags, &cli.IntFlag{ @@ -54,6 +57,7 @@ func GenerateFlags(options ...interface{}) (flags []cli.Flag, mappings map[strin Value: field.Value().(int), Usage: flagDescription, EnvVars: []string{envName}, + Aliases: aliases, }) } }