-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
74 lines (65 loc) · 1.83 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
package main
import (
"fmt"
"os"
"github.com/auriou/godebridaria/config"
"github.com/auriou/godebridaria/core"
flags "github.com/jessevdk/go-flags"
)
type Options struct {
Aria2Url func(string) `short:"u" long:"aria2-url" description:"url aria2 server"`
Aria2Secret func(string) `short:"s" long:"aria2-secret" description:"secret aria2 server"`
Port func(string) `short:"a" long:"address" description:"address of http service debrid > :8080"`
Daemon func() `short:"p" long:"http" description:"start http server"`
GetPin func() `short:"c" long:"getpin" description:"configure apikey for alldebrid"`
Download func(string) `short:"d" long:"download" description:"start download on aria2 one [url]"`
Debrid func(string) `short:"b" long:"debrid" description:"debrid url [url]"`
}
var options Options
var parser = flags.NewParser(&options, flags.Default)
func init() {
options.Aria2Url = func(aria2Url string) {
client := config.New()
client.SaveAria2Url(aria2Url)
fmt.Println("Saved")
}
options.Aria2Secret = func(aria2Secret string) {
client := config.New()
client.SaveAria2Secret(aria2Secret)
fmt.Println("Saved")
}
options.Port = func(address string) {
client := config.New()
client.SaveAddress(address)
fmt.Println("Saved")
}
options.Daemon = func() {
client := core.New()
client.StartApi()
}
options.Download = func(url string) {
client := core.New()
client.Download(url)
}
options.Debrid = func(url string) {
client := core.New()
client.Debrid(url)
}
options.GetPin = func() {
client := core.New()
client.Activate()
}
}
func main() {
/* TESTS
client := core.New()
client.Debrid("******")
*/
if _, err := parser.Parse(); err != nil {
if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type == flags.ErrHelp {
os.Exit(0)
} else {
os.Exit(1)
}
}
}