From e7607d78afb07f9ee4541f8e89e7f1e00257fea8 Mon Sep 17 00:00:00 2001 From: Vladislav Yarmak Date: Wed, 9 Jun 2021 15:49:44 +0300 Subject: [PATCH] show embedded version --- main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.go b/main.go index 29b1a32..a1d7cd9 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,10 @@ import ( "time" ) +var ( + version = "undefined" +) + func perror(msg string) { fmt.Fprintln(os.Stderr, "") fmt.Fprintln(os.Stderr, msg) @@ -31,6 +35,7 @@ type CLIArgs struct { list_ciphers bool ciphers string disableHTTP2 bool + showVersion bool } func list_ciphers() { @@ -52,6 +57,7 @@ func parse_args() CLIArgs { flag.BoolVar(&args.list_ciphers, "list-ciphers", false, "list ciphersuites") flag.StringVar(&args.ciphers, "ciphers", "", "colon-separated list of enabled ciphers") flag.BoolVar(&args.disableHTTP2, "disable-http2", false, "disable HTTP2") + flag.BoolVar(&args.showVersion, "version", false, "show program version and exit") flag.Parse() return args } @@ -59,6 +65,12 @@ func parse_args() CLIArgs { func run() int { args := parse_args() + if args.showVersion { + fmt.Println(version) + return 0 + } + + if args.list_ciphers { list_ciphers() return 0