forked from go-musicfox/go-musicfox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.go
51 lines (40 loc) · 1.44 KB
/
cli.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
package entry
import (
"fmt"
"log"
"github.com/go-musicfox/go-musicfox/pkg/commands"
"github.com/go-musicfox/go-musicfox/pkg/configs"
"github.com/go-musicfox/go-musicfox/pkg/constants"
"github.com/go-musicfox/go-musicfox/pkg/ui"
"github.com/go-musicfox/go-musicfox/utils"
neteaseutil "github.com/anhoder/netease-music/util"
"github.com/gookit/gcli/v2"
)
func runCLI() {
log.SetOutput(utils.LogWriter())
app := gcli.NewApp()
app.Name = constants.AppName
app.Version = constants.AppVersion
app.Description = constants.AppDescription
app.GOptsBinder = func(gf *gcli.Flags) {
gf.BoolOpt(&commands.GlobalOptions.PProfMode, "pprof", "p", false, "enable PProf mode")
}
// 加载config
utils.LoadIniConfig()
logo := utils.GetAlphaAscii(app.Name)
randomColor := ui.GetPrimaryColor()
logoColorful := ui.SetFgStyle(logo, randomColor)
gcli.AppHelpTemplate = fmt.Sprintf(constants.AppHelpTemplate, logoColorful)
app.Logo.Text = logoColorful
// 更新netease配置
neteaseutil.UNMSwitch = configs.ConfigRegistry.UNMSwitch
neteaseutil.Sources = configs.ConfigRegistry.UNMSources
neteaseutil.SearchLimit = configs.ConfigRegistry.UNMSearchLimit
neteaseutil.EnableLocalVip = configs.ConfigRegistry.UNMEnableLocalVip
neteaseutil.UnlockSoundEffects = configs.ConfigRegistry.UNMUnlockSoundEffects
playerCommand := commands.NewPlayerCommand()
app.Add(playerCommand)
app.Add(commands.NewConfigCommand())
app.DefaultCommand(playerCommand.Name)
app.Run()
}