mirror of
https://github.com/safing/portbase
synced 2025-09-01 10:09:50 +00:00
38 lines
619 B
Go
38 lines
619 B
Go
package module
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
|
|
"github.com/safing/portbase/info"
|
|
"github.com/safing/portbase/modules"
|
|
)
|
|
|
|
var showVersion bool
|
|
|
|
func init() {
|
|
modules.Register("info", prep, nil, nil)
|
|
|
|
flag.BoolVar(&showVersion, "version", false, "show version and exit")
|
|
}
|
|
|
|
func prep() error {
|
|
err := info.CheckVersion()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if printVersion() {
|
|
return modules.ErrCleanExit
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// printVersion prints the version, if requested, and returns if it did so.
|
|
func printVersion() (printed bool) {
|
|
if showVersion {
|
|
fmt.Println(info.FullVersion())
|
|
return true
|
|
}
|
|
return false
|
|
}
|