-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (44 loc) · 887 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
44
45
46
47
48
49
package main
import (
"log"
"os"
"path/filepath"
"github.com/urfave/cli"
)
func main() {
// CLI app info
app := cli.NewApp()
app.Name = "slatt"
app.Usage = "a Go tool that helps you easily transfer files from one computer to another"
// CLI commands
app.Commands = []cli.Command{
// Send file
{
Name: "send",
Aliases: []string{"s"},
Usage: "send a file or directory",
Action: func(c *cli.Context) error {
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
handleErr(err, "")
filename := c.Args().Get(0)
send(dir, filename)
// println(getIP())
return nil
},
},
// Receive file
{
Name: "receive",
Aliases: []string{"r"},
Usage: "receive a file or directory",
Action: func(c *cli.Context) error {
receive()
return nil
},
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}