diff --git a/src/go.mod b/src/go.mod index 00a2fd74..4cf08322 100644 --- a/src/go.mod +++ b/src/go.mod @@ -18,7 +18,7 @@ require ( github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 github.com/paypal/gatt v0.0.0-20151011220935-4ae819d591cf // indirect github.com/satori/go.uuid v1.2.0 - github.com/urfave/cli v1.22.1 + github.com/urfave/cli/v2 v2.2.0 github.com/youtube/vitess v2.1.1+incompatible golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 ) diff --git a/src/go.sum b/src/go.sum index 963681b7..6565b9cd 100644 --- a/src/go.sum +++ b/src/go.sum @@ -44,6 +44,9 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5I github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA= +github.com/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4= +github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= github.com/youtube/vitess v2.1.1+incompatible h1:SE+P7DNX/jw5RHFs5CHRhZQjq402EJFCD33JhzQMdDw= github.com/youtube/vitess v2.1.1+incompatible/go.mod h1:hpMim5/30F1r+0P8GGtB29d0gWHr0IZ5unS+CG0zMx8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/src/kr/debugaws.go b/src/kr/debugaws.go index 671d22d8..b57758e8 100644 --- a/src/kr/debugaws.go +++ b/src/kr/debugaws.go @@ -5,7 +5,7 @@ import ( "os" "time" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" . "krypt.co/kr/common/analytics" . "krypt.co/kr/common/util" . "krypt.co/kr/common/aws" diff --git a/src/kr/kr.go b/src/kr/kr.go index 6c21ba1d..13e9c111 100644 --- a/src/kr/kr.go +++ b/src/kr/kr.go @@ -11,7 +11,6 @@ import ( "fmt" "io" "io/ioutil" - "krypt.co/kr/common/version" "net/http" "os" "os/exec" @@ -20,8 +19,9 @@ import ( "time" "github.com/atotto/clipboard" - "github.com/urfave/cli" - + "github.com/urfave/cli/v2" + + "krypt.co/kr/common/version" . "krypt.co/kr/common/analytics" . "krypt.co/kr/common/persistance" . "krypt.co/kr/common/protocol" @@ -528,139 +528,143 @@ func main() { app.Usage = "communicate with Krypton and krd - the Krypton daemon" app.Version = version.CURRENT_VERSION.String() app.Flags = []cli.Flag{} - app.Commands = []cli.Command{ - cli.Command{ + app.Commands = []*cli.Command{ + { Name: "pair", Usage: "Initiate pairing of this workstation with a phone running Krypton", Flags: []cli.Flag{ - cli.BoolFlag{ + &cli.BoolFlag{ Name: "force", Usage: "Do not ask for confirmation to unpair a currently paired device", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "name, n", Usage: "WorkstationName for this computer", }, }, Action: pairCommand, }, - cli.Command{ + { Name: "me", Usage: "Print your SSH public key", Action: meCommand, - Subcommands: []cli.Command{ - cli.Command{ + Subcommands: []*cli.Command{ + &cli.Command{ Name: "pgp", Usage: "Print your PGP public key", Action: mePGPCommand, }, }, }, - cli.Command{ + { Name: "codesign", Usage: "Setup Krypton to sign git commits", Flags: []cli.Flag{ - cli.BoolFlag{ + &cli.BoolFlag{ Name: "interactive, i", Usage: "Prompt before each step", }, }, Action: codesignCommand, - Subcommands: []cli.Command{ - cli.Command{ + Subcommands: []*cli.Command{ + { Name: "uninstall", Usage: "Uninstall Krypton codesigning", Action: codesignUninstallCommand, }, - cli.Command{ + { Name: "test", Usage: "Test Krypton codesigning", Action: codesignTestCommand, }, - cli.Command{ + { Name: "on", Usage: "Turn on auto commit signing (requires git v2.0+)", Action: codesignOnCommand, }, - cli.Command{ + { Name: "off", Usage: "Turn off auto commit signing", Action: codesignOffCommand, }, }, }, - cli.Command{ + { Name: "copy", Usage: "Copy your SSH public key to the clipboard", Action: copyCommand, - Subcommands: []cli.Command{ - cli.Command{ + Subcommands: []*cli.Command{ + { Name: "pgp", Usage: "Copy your PGP public key to the clipboard.", Action: copyPGPCommand, }, }, }, - cli.Command{ + { Name: "env", Usage: "Print useful environment variables for configuring kr/krd", Action: envCommand, }, - cli.Command{ + { Name: "sshconfig", Usage: "Verify SSH is configured to use Krypton", Action: sshConfigCommand, Flags: []cli.Flag{ - cli.BoolFlag{ + &cli.BoolFlag{ Name: "print", Usage: "Print Krypton SSH config block", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "force", Usage: "Force append the Krypton SSH config block even if other Krypton-related lines are present", }, }, }, - cli.Command{ + { Name: "transfer", Usage: "Authorize a new Krypton device to access of your servers", Action: transferCommand, Flags: []cli.Flag{ - cli.BoolFlag{ + &cli.BoolFlag{ Name: "dry-run, d", Usage: "Do a dry-run and preview all servers that kr will try to add the new public key too", }, }, }, - cli.Command{ - Name: "aws,bitbucket,digitalocean,gcp,github,ghe,gitlab,heroku", - Usage: "Upload your public key this service", + { + Name: "aws,bitbucket,digitalocean,gcp,github,ghe,gitlab,heroku", + Usage: "Upload your public key this service", + Action: func(c *cli.Context) (err error) { + PrintErr(os.Stderr, Red("Pick one service to upload your public key to!")) + return + }, }, - cli.Command{ + { Name: "github", Usage: "Upload your public key to GitHub. Copies your public key to the clipboard and opens GitHub settings", Action: githubCommand, Hidden: true, - Subcommands: []cli.Command{ - cli.Command{ + Subcommands: []*cli.Command{ + { Name: "pgp", Usage: "Upload your PGP public key to GitHub. Copies your public key to the clipboard and opens GitHub settings", Action: githubPGPCommand, }, }, }, - cli.Command{ + { Name: "ghe", Usage: "Upload your public key to GitHub Enterprise. Copies your public key to the clipboard and opens GitHub Enterprise settings", Action: gheCommand, Hidden: true, - Subcommands: []cli.Command{ - cli.Command{ + Subcommands: []*cli.Command{ + { Name: "pgp", Usage: "Upload your PGP public key to GitHub Enterprise. Copies your public key to the clipboard and opens GitHub Enterprise settings", Action: ghePGPCommand, Flags: []cli.Flag{ - cli.StringFlag{ + &cli.StringFlag{ Name: "url", Usage: "GitHub Enterprise URL, i.e. github.mit.edu", }, @@ -668,75 +672,79 @@ func main() { }, }, Flags: []cli.Flag{ - cli.StringFlag{ + &cli.StringFlag{ Name: "url", Usage: "GitHub Enterprise URL, i.e. github.mit.edu", }, }, }, - cli.Command{ + { Name: "gitlab", Usage: "Upload your public key to GitLab. Copies your public key to the clipboard and opens your GitLab profile", Action: gitlabCommand, Hidden: true, }, - cli.Command{ + { Name: "bitbucket", Usage: "Upload your public key to BitBucket. Copies your public key to the clipboard and opens BitBucket settings", Action: bitbucketCommand, Hidden: true, }, - cli.Command{ - Name: "digitalocean", - Usage: "Upload your public key to DigitalOcean. Copies your public key to the clipboard and opens DigitalOcean settings", - Action: digitaloceanCommand, - Hidden: true, - }, - cli.Command{ - Name: "digital-ocean", - Usage: "Upload your public key to DigitalOcean. Copies your public key to the clipboard and opens DigitalOcean settings", - Action: digitaloceanCommand, - Hidden: true, + { + Name: "digitalocean", + Aliases: []string{"digital-ocean"}, + Usage: "Upload your public key to DigitalOcean. Copies your public key to the clipboard and opens DigitalOcean settings", + Action: digitaloceanCommand, + Hidden: true, }, - cli.Command{ + { Name: "heroku", Usage: "Upload your public key to Heroku. Copies your public key to the clipboard and opens Heroku settings", Action: herokuCommand, Hidden: true, }, - cli.Command{ + { Name: "aws", Usage: "Upload your public key to Amazon Web Services. Copies your public key to the clipboard and opens the AWS Console", Action: awsCommand, Hidden: true, }, - cli.Command{ + { Name: "gcp", Usage: "Upload your public key to Google Cloud. Copies your public key to the clipboard and opens the Google Cloud Console", Action: gcloudCommand, Hidden: true, }, - cli.Command{ + { Name: "restart", Usage: "Restart the Krypton daemon", Action: restartCommand, }, - cli.Command{ + { Name: "upgrade", Usage: "Upgrade Krypton on this workstation", Action: upgradeCommand, }, - cli.Command{ + { + Name: "update", + Action: upgradeCommand, + Hidden: true, + }, + { Name: "unpair", Usage: "Unpair this workstation from a phone running Krypton", Action: unpairCommand, }, - cli.Command{ + { Name: "uninstall", Usage: "Uninstall Krypton from this workstation", Action: uninstallCommand, }, - cli.Command{ + { + Name: "remove", + Action: uninstallCommand, + }, + { Name: "debugaws", Usage: "Check connectivity to AWS SQS", Action: debugAWSCommand, diff --git a/src/kr/kr_pgp.go b/src/kr/kr_pgp.go index 2bf986bb..141f868d 100644 --- a/src/kr/kr_pgp.go +++ b/src/kr/kr_pgp.go @@ -10,7 +10,8 @@ import ( "strings" "time" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" + . "krypt.co/kr/common/util" . "krypt.co/kr/common/analytics" . "krypt.co/kr/daemon/client" diff --git a/src/kr/kr_unix.go b/src/kr/kr_unix.go index b9169faa..44ab9138 100644 --- a/src/kr/kr_unix.go +++ b/src/kr/kr_unix.go @@ -6,7 +6,7 @@ import ( "os" "os/exec" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" . "krypt.co/kr/common/analytics" . "krypt.co/kr/common/socket" ) diff --git a/src/kr/sshconfig.go b/src/kr/sshconfig.go index 02014d0e..a35a97ec 100644 --- a/src/kr/sshconfig.go +++ b/src/kr/sshconfig.go @@ -10,7 +10,7 @@ import ( "time" "strconv" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" . "krypt.co/kr/common/util" ) diff --git a/src/kr/transfer_authority.go b/src/kr/transfer_authority.go index e6bb6e16..dc2fbc35 100644 --- a/src/kr/transfer_authority.go +++ b/src/kr/transfer_authority.go @@ -8,7 +8,8 @@ import ( "strings" "time" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" + . "krypt.co/kr/common/persistance" . "krypt.co/kr/common/protocol" . "krypt.co/kr/common/socket" diff --git a/src/krgpg/main.go b/src/krgpg/main.go index 6e4ec575..a5128b5e 100644 --- a/src/krgpg/main.go +++ b/src/krgpg/main.go @@ -12,7 +12,7 @@ import ( "strings" "time" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" . "krypt.co/kr/common/protocol" . "krypt.co/kr/common/util" @@ -53,49 +53,49 @@ func main() { app.Name = "krgpg" app.Usage = "Sign git commits with your Krypton key" app.Flags = []cli.Flag{ - cli.BoolFlag{ + &cli.BoolFlag{ Name: "a", Usage: "Ouput ascii armor", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "b,detach-sign", Usage: "Create a detached signature", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "s,sign", Usage: "Create a signature", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "u,local-user", Value: "", Usage: "User ID", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "status-fd", Value: "", Usage: "status file descriptor", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "bsau", Usage: "Git method of passing in detach-sign ascii armor flags", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "verify", Usage: "Verify a signature", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "keyid-format", Usage: "Key ID format", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "batch", Hidden: true, }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "no-tty", Hidden: true, }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "yes", Hidden: true, },