osc-mqtt-bridge/flags.go

36 lines
713 B
Go
Raw Normal View History

2023-04-20 22:28:28 -05:00
package main
import (
"flag"
"fmt"
"os"
)
// Flags Configuration options for cli execution
type Flags struct {
ConfigPath string
}
// InitFlags Parses configuration options
func (a *App) InitFlags() {
app.flags = new(Flags)
flag.Usage = func() {
fmt.Printf(serviceName + ": " + serviceDescription + ".\n\nUsage:\n")
flag.PrintDefaults()
}
var printVersion bool
flag.BoolVar(&printVersion, "v", false, "Print version")
usage := "Load configuration from `FILE`"
flag.StringVar(&app.flags.ConfigPath, "config", "", usage)
flag.StringVar(&app.flags.ConfigPath, "c", "", usage+" (shorthand)")
flag.Parse()
if printVersion {
fmt.Println(serviceName + ": " + serviceVersion)
os.Exit(0)
}
}