add version
ci/woodpecker/push/goreleaser Pipeline was successful Details
ci/woodpecker/tag/goreleaser Pipeline was successful Details

Signed-off-by: jolheiser <john.olheiser@gmail.com>
main v0.0.1
jolheiser 2022-10-11 21:27:51 -05:00
parent aa4e8907d9
commit d42bf431d6
Signed by: jolheiser
GPG Key ID: B853ADA5DA7BBF7A
1 changed files with 16 additions and 2 deletions

18
main.go
View File

@ -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 {