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 (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
@ -14,11 +15,24 @@ import (
|
|||
var Version = "develop"
|
||||
|
||||
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")
|
||||
return
|
||||
}
|
||||
host := os.Args[1]
|
||||
host := fs.Arg(0)
|
||||
|
||||
r, err := Check(host)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue