-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.go
More file actions
58 lines (48 loc) · 1.03 KB
/
Copy pathmain.go
File metadata and controls
58 lines (48 loc) · 1.03 KB
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
package main
import (
"fmt"
"os"
"re-asmr-spider/app"
"re-asmr-spider/cli"
"re-asmr-spider/config"
"re-asmr-spider/spider"
"re-asmr-spider/ui"
"re-asmr-spider/version"
)
func main() {
// 解析命令行参数
flags := cli.ParseFlags()
// 处理版本信息(不需要配置)
if flags.IsVersionMode() {
// 使用默认应用名称
fmt.Printf("ASMR Downloader v%s\n", version.Version)
return
}
// 处理帮助信息(不需要配置)
if flags.IsHelpMode() {
cli.PrintHelp()
return
}
// 初始化配置
cfg, err := config.GetConfig()
if err != nil {
fmt.Printf("Failed to load config: %v\n", err)
os.Exit(1)
}
// 初始化spider包(包括i18n和代理)
if err := spider.InitSpider(cfg); err != nil {
fmt.Printf("Failed to initialize: %v\n", err)
os.Exit(1)
}
// 创建应用实例
application := app.New()
// CLI模式
if flags.IsCLIMode() {
command := cli.NewCommand(flags, application)
command.ApplyFlags()
command.Execute()
return
}
// 交互模式
ui.RunInteractive(application)
}