diff --git a/main.go b/main.go index b099baa..025d260 100644 --- a/main.go +++ b/main.go @@ -1,11 +1,17 @@ package main import ( + "fmt" "math" + "os" "runtime" "sync" ) +const version = "v1.0.1" + +const usage = "heat [-v|--verbose]" + func heat() { var t float64 = math.MaxFloat64 for { @@ -17,6 +23,15 @@ func heat() { } func main() { + if len(os.Args) > 1 { + if verbose(os.Args) { + fmt.Printf("heat version %v\n", version) + os.Exit(0) + } else { + fmt.Fprintf(os.Stderr, "usage: %v\n", usage) + os.Exit(1) + } + } wg := sync.WaitGroup{} wg.Add(1) for i := 0; i < runtime.NumCPU(); i++ { @@ -24,3 +39,14 @@ func main() { } wg.Wait() } + +func verbose(args []string) bool { + r := false + for _, arg := range args { + switch arg { + case "-v", "-version", "--version", "v", "version": + r = true + } + } + return r +}