Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version flag to print out app version #603

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var (
flagWgConfTemplate string
flagBasePath string
flagSubnetRanges string
flagVersion = false
)

const (
Expand Down Expand Up @@ -94,6 +95,7 @@ func init() {
flag.StringVar(&flagBasePath, "base-path", util.LookupEnvOrString("BASE_PATH", flagBasePath), "The base path of the URL")
flag.StringVar(&flagSubnetRanges, "subnet-ranges", util.LookupEnvOrString("SUBNET_RANGES", flagSubnetRanges), "IP ranges to choose from when assigning an IP for a client.")
flag.IntVar(&flagSessionMaxDuration, "session-max-duration", util.LookupEnvOrInt("SESSION_MAX_DURATION", flagSessionMaxDuration), "Max time in days a remembered session is refreshed and valid.")
flag.BoolVar(&flagVersion, "version", false, "Prints the app version.")

var (
smtpPasswordLookup = util.LookupEnvOrString("SMTP_PASSWORD", flagSmtpPassword)
Expand Down Expand Up @@ -152,7 +154,7 @@ func init() {
telegram.LogLevel = lvl

// print only if log level is INFO or lower
if lvl <= log.INFO {
if lvl <= log.INFO && !flagVersion {
// print app information
fmt.Println("Wireguard UI")
fmt.Println("App Version\t:", appVersion)
Expand All @@ -173,6 +175,11 @@ func init() {
}

func main() {
if flagVersion {
fmt.Println(appVersion)
os.Exit(0)
}

db, err := jsondb.New("./db")
if err != nil {
panic(err)
Expand Down