Add version flag for gui, issue #39

This commit is contained in:
Milan Nikolic
2024-11-04 12:31:08 +01:00
parent 5b2ed5233b
commit 4f23f228a8

View File

@@ -5,11 +5,13 @@ import (
"context"
_ "embed"
"errors"
"flag"
"fmt"
"image/gif"
"image/png"
"net/url"
"os"
"path/filepath"
"runtime/debug"
"slices"
"strconv"
@@ -62,6 +64,8 @@ func init() {
}
func main() {
parseFlags()
iup.Open()
defer iup.Close()
@@ -98,6 +102,27 @@ func main() {
iup.MainLoop()
}
func parseFlags() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s <command> [<flags>]\n\n", filepath.Base(os.Args[0]))
fmt.Fprintf(os.Stderr, "\nCommands:\n")
fmt.Fprintf(os.Stderr, "\n version\n \tPrint version\n\n")
}
flag.NewFlagSet("version", flag.ExitOnError)
flag.Parse()
if flag.NArg() >= 1 {
if flag.Arg(0) == "version" {
fmt.Println(filepath.Base(os.Args[0]), appVersion)
os.Exit(0)
} else {
flag.Usage()
os.Exit(1)
}
}
}
func options() cbconvert.Options {
var opts cbconvert.Options
opts.Recursive = iup.GetHandle("Recursive").GetAttribute("VALUE") == "ON"