From 3c0bc4f1b0e77c5869266bf8e3261bb727c857e1 Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Wed, 17 Aug 2022 23:55:15 +0200 Subject: [PATCH] added -v --- README.md | 1 + init.go | 7 ++++++- main.go | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e284f64..a87efab 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ Usage of ./gocc: save config file with current configuration and exit -t int amount of threads (0 = infinite) (default 16) + -v show version and exit ``` #### Providing a Go module diff --git a/init.go b/init.go index 4052a4a..8742664 100644 --- a/init.go +++ b/init.go @@ -15,9 +15,14 @@ func Init() { flag.Parse() var err error + if *ShowVersion { + fmt.Printf("gocc %s\n", VERSION) + os.Exit(0) + } + if *FindConfigFile { if configFilePath, err := configfile.Path("json"); err == nil { - Println(configFilePath) + fmt.Println(configFilePath) os.Exit(0) } } diff --git a/main.go b/main.go index 899caa9..a4cd939 100644 --- a/main.go +++ b/main.go @@ -16,6 +16,8 @@ import ( "git.milar.in/milarin/channel" ) +var VERSION = "v1.0.3" + // globals var ( OutputFileTmpl = template.New("output-file") @@ -53,6 +55,8 @@ var ( SaveConfigFile = flag.Bool("saveconfig", false, "save config file with current configuration and exit") IgnoreConfigFile = flag.Bool("ignoreconfig", false, "dont read any config file") FindConfigFile = flag.Bool("findconfig", false, "print config file path and exit") + + ShowVersion = flag.Bool("v", false, "show version and exit") ) func main() {