add version flag
This commit is contained in:
parent
6a0644d9af
commit
d2748259cb
1 changed files with 12 additions and 3 deletions
|
@ -17,14 +17,23 @@ import (
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var Version string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
quiet := pflag.BoolP("quiet", "q", false, "Disable logging")
|
quietFlag := pflag.BoolP("quiet", "q", false, "Disable logging")
|
||||||
verbose := pflag.Bool("debug", false, "Enable debug logging (beats --quiet)")
|
verboseFlag := pflag.Bool("debug", false, "Enable debug logging (beats --quiet)")
|
||||||
|
versionFlag := pflag.BoolP("version", "v", false, "Show version information")
|
||||||
pflag.BoolVarP(&configuration.DryRun, "dry-run", "d", false, "Show what this application *would* do")
|
pflag.BoolVarP(&configuration.DryRun, "dry-run", "d", false, "Show what this application *would* do")
|
||||||
pflag.StringVarP(&configuration.ConfigFile, "config", "c", "", "Path to config file (default: $WorkDir/config.yaml)")
|
pflag.StringVarP(&configuration.ConfigFile, "config", "c", "", "Path to config file (default: $WorkDir/config.yaml)")
|
||||||
|
|
||||||
pflag.Parse()
|
pflag.Parse()
|
||||||
logging.NewSlogLogger(*quiet, *verbose)
|
|
||||||
|
if *versionFlag {
|
||||||
|
fmt.Println("mailcow-admin-aliases " + Version)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
logging.NewSlogLogger(*quietFlag, *verboseFlag)
|
||||||
|
|
||||||
var cfg configuration.Config
|
var cfg configuration.Config
|
||||||
err := cfg.LoadFromDisk()
|
err := cfg.LoadFromDisk()
|
||||||
|
|
Loading…
Reference in a new issue