-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (40 loc) · 784 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"fmt"
"log"
"os"
"github.com/urfave/cli/v2"
)
func main() {
app := &cli.App{
Name: "HeathChecker",
Usage: "Samll tool to check websit is running or down",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "domain",
Aliases: []string{"d"},
Usage: "domain which need be checked",
Required: true,
},
&cli.StringFlag{
Name: "ip",
Usage: "ip which need be checked",
Aliases: []string{"p"},
Required: false,
},
},
Action: func(ctx *cli.Context) error {
port := ctx.String("port")
if ctx.String("port") == "" {
port = "80"
}
status := Check(ctx.String("domain"), port)
fmt.Print(status)
return nil
},
}
error := app.Run(os.Args)
if error != nil {
log.Fatal(error)
}
}