osc-mqtt-bridge/flags.go
2023-04-20 22:35:43 -05:00

36 lines
713 B
Go

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