From 2f59b8ac22d9bf98ca52bd857b6963473a6ce9c5 Mon Sep 17 00:00:00 2001 From: Austin Cherry Date: Thu, 24 Jan 2019 15:11:53 -0600 Subject: [PATCH] AUTH-1211: print all the versions --- cmd/cloudflared/main.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/cmd/cloudflared/main.go b/cmd/cloudflared/main.go index 47fb63a7..a5155df0 100644 --- a/cmd/cloudflared/main.go +++ b/cmd/cloudflared/main.go @@ -21,6 +21,7 @@ import ( const ( developerPortal = "https://developers.cloudflare.com/argo-tunnel" licenseUrl = developerPortal + "/license/" + versionText = "Print the version" ) var ( @@ -51,6 +52,12 @@ func main() { // Windows service manager closes this channel when it receives stop command. graceShutdownC := make(chan struct{}) + cli.VersionFlag = &cli.BoolFlag{ + Name: "version", + Aliases: []string{"v", "V"}, + Usage: versionText, + } + app := &cli.App{} app.Name = "cloudflared" app.Usage = "Cloudflare's command-line tool and agent" @@ -64,14 +71,14 @@ func main() { app.Flags = flags() app.Action = action(Version, shutdownC, graceShutdownC) app.Before = tunnel.Before - app.Commands = commands() + app.Commands = commands(cli.ShowVersion) tunnel.Init(Version, shutdownC, graceShutdownC) // we need this to support the tunnel sub command... access.Init(shutdownC, graceShutdownC) runApp(app, shutdownC, graceShutdownC) } -func commands() []*cli.Command { +func commands(version func(c *cli.Context)) []*cli.Command { cmds := []*cli.Command{ { Name: "update", @@ -84,6 +91,15 @@ Otherwise, does nothing. To determine if an update happened in a script, check for error code 64.`, }, + { + Name: "version", + Action: func(c *cli.Context) (err error) { + version(c) + return nil + }, + Usage: versionText, + Description: versionText, + }, } cmds = append(cmds, tunnel.Commands()...) cmds = append(cmds, access.Commands()...)