mirror of
https://github.com/gen2brain/cbconvert
synced 2025-10-14 02:28:51 +02:00
Add version flag for gui, issue #39
This commit is contained in:
@@ -5,11 +5,13 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"errors"
|
"errors"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image/gif"
|
"image/gif"
|
||||||
"image/png"
|
"image/png"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -62,6 +64,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
parseFlags()
|
||||||
|
|
||||||
iup.Open()
|
iup.Open()
|
||||||
defer iup.Close()
|
defer iup.Close()
|
||||||
|
|
||||||
@@ -98,6 +102,27 @@ func main() {
|
|||||||
iup.MainLoop()
|
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 {
|
func options() cbconvert.Options {
|
||||||
var opts cbconvert.Options
|
var opts cbconvert.Options
|
||||||
opts.Recursive = iup.GetHandle("Recursive").GetAttribute("VALUE") == "ON"
|
opts.Recursive = iup.GetHandle("Recursive").GetAttribute("VALUE") == "ON"
|
||||||
|
Reference in New Issue
Block a user