From d182adba8c3f597de4538113ed97c3f6eeb68277 Mon Sep 17 00:00:00 2001 From: Timur Demin Date: Fri, 19 Feb 2021 16:57:16 +0500 Subject: [PATCH] Add version display --- cmd/gmnhg/main.go | 13 ++++++++++++- cmd/md2gmn/main.go | 13 +++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/cmd/gmnhg/main.go b/cmd/gmnhg/main.go index 854a711..a283e7e 100644 --- a/cmd/gmnhg/main.go +++ b/cmd/gmnhg/main.go @@ -143,12 +143,23 @@ func writeFile(dst string, contents []byte) error { return nil } +var version = "v0+HEAD" + func main() { - var outputDir, workingDir string + var ( + outputDir, workingDir string + isVersionCmd bool + ) flag.StringVar(&outputDir, "output", outputBase, "output directory (will be created if missing)") flag.StringVar(&workingDir, "working", "", "working directory (defaults to current directory)") + flag.BoolVar(&isVersionCmd, "version", false, "display version") flag.Parse() + if isVersionCmd { + println("gmnhg", version) + return + } + if workingDir != "" { if err := os.Chdir(workingDir); err != nil { panic(err) diff --git a/cmd/md2gmn/main.go b/cmd/md2gmn/main.go index f5b26b3..e13282f 100644 --- a/cmd/md2gmn/main.go +++ b/cmd/md2gmn/main.go @@ -25,14 +25,23 @@ import ( gemini "git.tdem.in/tdemin/gmnhg" ) +var version = "v0+HEAD" + func main() { var ( - input string - file *os.File + input string + file *os.File + isVersionCmd bool ) flag.StringVar(&input, "f", "", "input file") + flag.BoolVar(&isVersionCmd, "version", false, "display version") flag.Parse() + if isVersionCmd { + println("md2gmn", version) + return + } + if input != "" { var err error file, err = os.Open(input)