-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
64 lines (49 loc) · 1.25 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
ssh-chat-bot
A small chatbot for ssh-chat
*/
package main
import (
"flag"
"fmt"
"os"
"time"
"github.com/peterhellberg/ssh-chat-bot/herder"
)
const repoURL = "https://github.com/peterhellberg/ssh-chat-bot"
var buildCommit string
func main() {
var (
user = flag.String("n", "ssh-chat-bot", "Username")
owner = flag.String("o", "peter", "Bot owner username")
host = flag.String("h", "localhost", "Hostname")
port = flag.Int("p", 2022, "Port")
delay = flag.Duration("d", 2*time.Second, "Delay")
check = flag.Duration("c", 30*time.Second, "Duration between alive checks")
verbose = flag.Bool("v", false, "Verbose output")
)
flag.Usage = usage
flag.Parse()
h := herder.New(
herder.User(*user),
herder.Owner(*owner),
herder.Addr(fmt.Sprintf("%s:%d", *host, *port)),
herder.Delay(*delay),
herder.Check(*check),
herder.Verbose(*verbose),
)
if err := h.Run(); err != nil {
fmt.Printf("Error: %v\n", err)
os.Exit(1)
}
}
func usage() {
fmt.Fprintf(os.Stderr, "usage: ./ssh-chat-bot [-h hostname] [-v]\n\n")
if buildCommit != "" {
fmt.Fprintf(os.Stderr, "build: "+repoURL+"/commit/"+buildCommit+"\n\n")
}
fmt.Fprintf(os.Stderr, "flags:\n")
flag.PrintDefaults()
fmt.Fprintf(os.Stderr, "\n")
os.Exit(2)
}