-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
75 lines (70 loc) · 1.48 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
65
66
67
68
69
70
71
72
73
74
75
package main
import (
"github.com/null-dev/klipd/klipd"
"github.com/urfave/cli"
"log"
"os"
)
func main() {
var ip, password string
var port int
app := cli.NewApp()
app.Name = "klipd"
app.Usage = "Universal clipboard sync daemon."
app.Flags = []cli.Flag{
cli.IntFlag{
Name: "port",
Value: 9559,
Usage: "The port to bind or connect to",
Destination: &port,
},
cli.StringFlag{
Name: "password",
Usage: "The password to encrypt communications with",
Destination: &password,
},
}
app.Commands = []cli.Command{
{
Name: "client",
Aliases: []string{"c"},
Usage: "Run the daemon in 'client' mode.",
ArgsUsage: "--ip <server ip> --password <password>",
Action: func(c *cli.Context) {
if ip == "" {
log.Fatal("No IP specified!")
return
}
klipd.StartClient(password, ip, port)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "ip",
Usage: "The IP to connect to",
Destination: &ip,
},
},
},
{
Name: "server",
Aliases: []string{"s"},
Usage: "Run the daemon in 'server' mode.",
ArgsUsage: "--password <password>",
Action: func(c *cli.Context) {
klipd.StartServer(password, ip, port)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "ip",
Value: "0.0.0.0",
Usage: "The IP to bind to",
Destination: &ip,
},
},
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}