-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
63 lines (53 loc) · 1.11 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
package main
import (
"flag"
"fmt"
"os"
"github.com/emiraganov/sharef/cli"
cliconf "github.com/emiraganov/sharef/cli/conf"
log_prefixed "github.com/chappjc/logrus-prefix"
"github.com/sirupsen/logrus"
)
var verbose = flag.Int("v", 3, "verbosity")
func init() {
logrus.SetFormatter(&log_prefixed.TextFormatter{
FullTimestamp: true,
})
}
func main() {
// receive := flag.NewFlagSet("receive", flag.ExitOnError)
flag.Usage = func() {
s := `Usage:
push - Start sending/streaming files. More options are available.
pull - Start receiving files.
`
fmt.Fprintln(os.Stderr, s)
fmt.Fprintln(os.Stderr, "Options:")
flag.PrintDefaults()
}
flag.Parse()
logrus.SetLevel(logrus.Level(*verbose))
// Read any enviroment vars for
cliconf.ReadEnv()
args := flag.Args()
// We expect always some action argument:
if len(args) == 0 {
flag.Usage()
return
}
ParseArgs(args)
}
func ParseArgs(args []string) {
action := args[0]
args = args[1:]
switch action {
case "push":
cli.Push(args)
case "pull":
cli.Pull(args)
case "deamon":
cli.Deamon(args)
default:
fmt.Println("Unknown action")
}
}