Skip to content

Commit

Permalink
Add -V flag to print out version string
Browse files Browse the repository at this point in the history
  • Loading branch information
yamnikov-oleg committed Feb 9, 2017
1 parent 71dd993 commit 8a4eabd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package main

import (
"flag"
"fmt"
"log"
"os"
"os/exec"
Expand All @@ -22,11 +23,15 @@ var (
SingleInstance bool

CPUProfile string

Version string = "v0.1+"
ShowVersion bool
)

func init() {
flag.BoolVar(&SingleInstance, SIFlag, false, "Run an instance of projektor, not a daemon")
flag.StringVar(&CPUProfile, "cpuprofile", "", "Run CPU profiling and output results to the `file`")
flag.BoolVar(&ShowVersion, "V", false, "Display version of current projektor build.\n\tPlus sign means that the build includes several more commits over the release.")
}

func RunInstance() {
Expand Down Expand Up @@ -68,6 +73,11 @@ func RunDaemon() {
func main() {
flag.Parse()

if ShowVersion {
fmt.Printf("Projektor %v\n", Version)
os.Exit(0)
}

if CPUProfile != "" {
f, err := os.Create(CPUProfile)
if err != nil {
Expand Down

0 comments on commit 8a4eabd

Please sign in to comment.