add version
Signed-off-by: jolheiser <john.olheiser@gmail.com>main v0.0.1
parent
aa4e8907d9
commit
d42bf431d6
18
main.go
18
main.go
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -14,11 +15,24 @@ import (
|
||||||
var Version = "develop"
|
var Version = "develop"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if len(os.Args) < 2 {
|
fs := flag.NewFlagSet("isitup", flag.ExitOnError)
|
||||||
|
versionFlag := fs.Bool("version", false, "Display version and exit")
|
||||||
|
fs.BoolVar(versionFlag, "v", *versionFlag, "--version")
|
||||||
|
if err := fs.Parse(os.Args[1:]); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if *versionFlag {
|
||||||
|
fmt.Printf("isitup %s\n", Version)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if fs.NArg() < 1 {
|
||||||
fmt.Println("isitup requires a host to check")
|
fmt.Println("isitup requires a host to check")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
host := os.Args[1]
|
host := fs.Arg(0)
|
||||||
|
|
||||||
r, err := Check(host)
|
r, err := Check(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue