Add version display

This commit is contained in:
Timur Demin 2021-02-19 16:57:16 +05:00
parent ae794d9d59
commit d182adba8c
No known key found for this signature in database
GPG key ID: 9EDF3F9D9286FA20
2 changed files with 23 additions and 3 deletions

View file

@ -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)

View file

@ -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)