show embedded version

This commit is contained in:
Vladislav Yarmak 2021-06-09 15:49:44 +03:00
parent 2ff961ba56
commit e7607d78af
1 changed files with 12 additions and 0 deletions

12
main.go
View File

@ -10,6 +10,10 @@ import (
"time" "time"
) )
var (
version = "undefined"
)
func perror(msg string) { func perror(msg string) {
fmt.Fprintln(os.Stderr, "") fmt.Fprintln(os.Stderr, "")
fmt.Fprintln(os.Stderr, msg) fmt.Fprintln(os.Stderr, msg)
@ -31,6 +35,7 @@ type CLIArgs struct {
list_ciphers bool list_ciphers bool
ciphers string ciphers string
disableHTTP2 bool disableHTTP2 bool
showVersion bool
} }
func list_ciphers() { func list_ciphers() {
@ -52,6 +57,7 @@ func parse_args() CLIArgs {
flag.BoolVar(&args.list_ciphers, "list-ciphers", false, "list ciphersuites") flag.BoolVar(&args.list_ciphers, "list-ciphers", false, "list ciphersuites")
flag.StringVar(&args.ciphers, "ciphers", "", "colon-separated list of enabled ciphers") flag.StringVar(&args.ciphers, "ciphers", "", "colon-separated list of enabled ciphers")
flag.BoolVar(&args.disableHTTP2, "disable-http2", false, "disable HTTP2") flag.BoolVar(&args.disableHTTP2, "disable-http2", false, "disable HTTP2")
flag.BoolVar(&args.showVersion, "version", false, "show program version and exit")
flag.Parse() flag.Parse()
return args return args
} }
@ -59,6 +65,12 @@ func parse_args() CLIArgs {
func run() int { func run() int {
args := parse_args() args := parse_args()
if args.showVersion {
fmt.Println(version)
return 0
}
if args.list_ciphers { if args.list_ciphers {
list_ciphers() list_ciphers()
return 0 return 0