Skip to content

Commit

Permalink
Merge pull request #181 from anhoder/master
Browse files Browse the repository at this point in the history
refactor with foxful-cli
  • Loading branch information
anhoder committed Aug 26, 2023
2 parents cf50bfe + 43f517f commit eac171b
Show file tree
Hide file tree
Showing 163 changed files with 5,931 additions and 6,818 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ bin/
dist/
.release-env
go.work
go.work.sum
.vscode/
.devenv/
.envrc
Expand Down
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ run:
tests: true
# List of build tags, all linters use it.
# Default: [].
build-tags:
- wireinject
build-tags: []
# Which dirs to skip: issues from them won't be reported.
# Can use regexp here: `generated.*`, regexp is applied on full path,
# including the path prefix if one is set.
Expand Down
19 changes: 10 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,31 @@ module github.com/go-musicfox/go-musicfox
go 1.18

require (
github.com/anhoder/foxful-cli v0.1.0
github.com/bogem/id3v2/v2 v2.1.4
github.com/buger/jsonparser v1.1.1
github.com/charmbracelet/bubbles v0.16.1
github.com/charmbracelet/bubbletea v0.24.2
github.com/charmbracelet/lipgloss v0.7.1
github.com/ebitengine/purego v0.3.2
github.com/charmbracelet/lipgloss v0.8.0
github.com/ebitengine/purego v0.4.0
github.com/faiface/beep v1.1.0
github.com/fhs/gompd/v2 v2.3.0
github.com/fogleman/ease v0.0.0-20170301025033-8da417bf1776
github.com/frolovo22/tag v0.0.2
github.com/go-flac/flacpicture v0.3.0
github.com/go-musicfox/netease-music v1.4.1
github.com/go-musicfox/notificator v0.1.0
github.com/godbus/dbus/v5 v5.1.0
github.com/gookit/gcli/v2 v2.3.4
github.com/gookit/ini/v2 v2.2.2
github.com/lithammer/fuzzysearch v1.1.8
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/markthree/go-get-folder-size v0.3.4
github.com/mattn/go-runewidth v0.0.14
github.com/muesli/termenv v0.15.1
github.com/markthree/go-get-folder-size v0.5.0
github.com/mattn/go-runewidth v0.0.15
github.com/muesli/termenv v0.15.2
github.com/pkg/errors v0.9.1
github.com/shkh/lastfm-go v0.0.0-20191215035245-89a801c244e0
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/telanflow/cookiejar v0.0.0-20190719062046-114449e86aa5
github.com/tosone/minimp3 v1.0.1
github.com/tosone/minimp3 v1.0.2
go.etcd.io/bbolt v1.3.7
)

Expand All @@ -39,6 +37,7 @@ require (
github.com/cnsilvan/UnblockNeteaseMusic v0.0.0-20230310083816-92b59c95a366 // indirect
github.com/cocoonlife/goflac v0.0.0-20170210142907-50ea06ed5a9d // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/fogleman/ease v0.0.0-20170301025033-8da417bf1776 // indirect
github.com/forgoer/openssl v1.6.0 // indirect
github.com/go-flac/go-flac v1.0.0 // indirect
github.com/go-musicfox/requests v0.2.0 // indirect
Expand All @@ -51,6 +50,7 @@ require (
github.com/jfreymuth/oggvorbis v1.0.5 // indirect
github.com/jfreymuth/vorbis v1.0.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mewkiz/flac v1.0.8 // indirect
Expand All @@ -63,6 +63,7 @@ require (
github.com/muesli/reflow v0.3.0 // indirect
github.com/panjf2000/ants/v2 v2.8.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/sahilm/fuzzy v0.1.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/crypto v0.10.0 // indirect
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect
Expand Down
24 changes: 17 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/anhoder/foxful-cli v0.1.0 h1:lSaiqAsoB+/VebTedyl29QmNK+d4K+T0u4PHEv3Sbbk=
github.com/anhoder/foxful-cli v0.1.0/go.mod h1:U03HgMRwkemXtB8dac2QorgJnDft0QdHP9b2qa4do8A=
github.com/anhoder/gcli/v2 v2.3.5 h1:tiFK7xnZxNHIevEaRtfT4Cfhz4OYFcJaeB1S55dxxBU=
github.com/anhoder/gcli/v2 v2.3.5/go.mod h1:AOxm27rFzNDLpBrwbW1pAh3ofebpXOQk/9x009qC9y8=
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
Expand All @@ -13,6 +15,8 @@ github.com/charmbracelet/bubbles v0.16.1 h1:6uzpAAaT9ZqKssntbvZMlksWHruQLNxg49H5
github.com/charmbracelet/bubbles v0.16.1/go.mod h1:2QCp9LFlEsBQMvIYERr7Ww2H2bA7xen1idUDIzm/+Xc=
github.com/charmbracelet/lipgloss v0.7.1 h1:17WMwi7N1b1rVWOjMT+rCh7sQkvDU75B2hbZpc5Kc1E=
github.com/charmbracelet/lipgloss v0.7.1/go.mod h1:yG0k3giv8Qj8edTCbbg6AlQ5e8KNWpFujkNawKNhE2c=
github.com/charmbracelet/lipgloss v0.8.0 h1:IS00fk4XAHcf8uZKc3eHeMUTCxUH6NkaTrdyCQk84RU=
github.com/charmbracelet/lipgloss v0.8.0/go.mod h1:p4eYUZZJ/0oXTuCQKFF8mqyKCz0ja6y+7DniDDw5KKU=
github.com/cocoonlife/testify v0.0.0-20160218172820-792cc1faeb64 h1:LjPYdzoFSAJ5Tr/ElL8kzTJghXgpnOjJVbgd1UvZB1o=
github.com/cocoonlife/testify v0.0.0-20160218172820-792cc1faeb64/go.mod h1:LoCAz53rbPcqs8Da2BjB/yDy4gxMtiSQmqnYI/DGH+U=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY=
Expand All @@ -21,8 +25,8 @@ github.com/d4l3k/messagediff v1.2.2-0.20190829033028-7e0a312ae40b/go.mod h1:Oozb
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ebitengine/purego v0.3.2 h1:+pV+tskAkn/bxEcUzGtDfw2VAe3bRQ26kdzFjPPrCww=
github.com/ebitengine/purego v0.3.2/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
github.com/ebitengine/purego v0.4.0 h1:RQVuMIxQPQ5iCGEJvjQ17YOK+1tMKjVau2FUMvXH4HE=
github.com/ebitengine/purego v0.4.0/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
github.com/fhs/gompd/v2 v2.3.0 h1:wuruUjmOODRlJhrYx73rJnzS7vTSXSU7pWmZtM3VPE0=
github.com/fhs/gompd/v2 v2.3.0/go.mod h1:nNdZtcpD5VpmzZbRl5rV6RhxeMmAWTxEsSIMBkmMIy4=
github.com/fogleman/ease v0.0.0-20170301025033-8da417bf1776 h1:VRIbnDWRmAh5yBdz+J6yFMF5vso1It6vn+WmM/5l7MA=
Expand Down Expand Up @@ -96,13 +100,14 @@ github.com/jfreymuth/vorbis v1.0.2/go.mod h1:DoftRo4AznKnShRl1GxiTFCseHr4zR9BN3T
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/jszwec/csvutil v1.5.1/go.mod h1:Rpu7Uu9giO9subDyMCIQfHVDuLrcaC36UA4YcJjGBkg=
github.com/lithammer/fuzzysearch v1.1.8 h1:/HIuJnjHuXS8bKaiTMeeDlW2/AyIWk2brx1V8LFgLN4=
github.com/lithammer/fuzzysearch v1.1.8/go.mod h1:IdqeyBClc3FFqSzYq/MXESsS4S0FsZ5ajtkr5xPLts4=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/markthree/go-get-folder-size v0.3.4 h1:uflPpLVzg0G1y+WgcushNkVfsB2JoKlDUjNDxsjf9v4=
github.com/markthree/go-get-folder-size v0.3.4/go.mod h1:wfUR1y12nyc0lR9bOZEu7ZcK/uEmb+W5eU55ABhUdKY=
github.com/markthree/go-get-folder-size v0.5.0 h1:ZJMayf44D/D2hsINZ/Asc4gP2b56svYzyim6XghqM74=
github.com/markthree/go-get-folder-size v0.5.0/go.mod h1:FZ/vUFAP8XWp4Y9SqCQEuYz0geLHS9O0yTlIDXNmv7U=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
Expand All @@ -111,6 +116,8 @@ github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzp
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mewkiz/flac v1.0.7/go.mod h1:yU74UH277dBUpqxPouHSQIar3G1X/QIclVbFahSd1pU=
github.com/mewkiz/flac v1.0.8 h1:cophRjvafteDGmqsfXRK28YAX6l8wy19QxTHruEEg1s=
github.com/mewkiz/flac v1.0.8/go.mod h1:l7dt5uFY724eKVkHQtAJAQSkhpC3helU3RDxN0ESAqo=
Expand All @@ -131,8 +138,8 @@ github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELU
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
github.com/muesli/termenv v0.15.1 h1:UzuTb/+hhlBugQz28rpzey4ZuKcZ03MeKsoG7IJZIxs=
github.com/muesli/termenv v0.15.1/go.mod h1:HeAQPTzpfs016yGtA4g00CsdYnVLJvxsS4ANqrZs2sQ=
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
github.com/panjf2000/ants/v2 v2.8.0 h1:4p4gPabD6iNM9Y5NpMc0g0L15uXDmfn6jkW5KP+oiHQ=
github.com/panjf2000/ants/v2 v2.8.0/go.mod h1:KIBmYG9QQX5U2qzFP/yQJaq/nSb6rahS9iEHkrCMgM8=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand All @@ -144,6 +151,8 @@ github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/sahilm/fuzzy v0.1.0 h1:FzWGaw2Opqyu+794ZQ9SYifWv2EIXpwP4q8dY1kDAwI=
github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 h1:JIAuq3EEf9cgbU6AtGPK4CTG3Zf6CKMNqf0MHTggAUA=
Expand All @@ -160,6 +169,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/telanflow/cookiejar v0.0.0-20190719062046-114449e86aa5 h1:gTQl5nPlc9B53vFOKM8aJHwxB2BW2kM49PVR5526GBg=
github.com/telanflow/cookiejar v0.0.0-20190719062046-114449e86aa5/go.mod h1:qNgA5MKwTh103SxGTooqZMiKxZTaV9UV3KjN7I7Drig=
github.com/tosone/minimp3 v1.0.2 h1:htFE2EbP7Y4CJ8KGW9c55tKWRpzv9kXkEmCYGxFzVjA=
github.com/tosone/minimp3 v1.0.2/go.mod h1:N6vjknGR7PboMTyJVhe/7RHNQiIc0jWZxFKlSWdfzwc=
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
Expand Down Expand Up @@ -228,7 +239,6 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
Expand Down
6 changes: 3 additions & 3 deletions pkg/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"path"

"github.com/anhoder/foxful-cli/util"
"github.com/go-musicfox/go-musicfox/pkg/constants"
"github.com/go-musicfox/go-musicfox/pkg/ui"
"github.com/go-musicfox/go-musicfox/utils"
"github.com/gookit/gcli/v2"
"github.com/muesli/termenv"
Expand All @@ -16,8 +16,8 @@ func NewConfigCommand() *gcli.Command {
Name: "config",
UseFor: "Print configuration file to be loaded",
Func: func(_ *gcli.Command, _ []string) error {
var configPath = ui.SetFgStyle(path.Join(utils.GetLocalDataDir(), constants.AppIniFile), termenv.ANSICyan)
fmt.Printf("\nLoaded Configuration File: %s\n", configPath)
var configPath = util.SetFgStyle(path.Join(utils.GetLocalDataDir(), constants.AppIniFile), termenv.ANSICyan)
fmt.Printf("Loaded Configuration File:\n\t%s\n", configPath)
return nil
},
}
Expand Down
37 changes: 22 additions & 15 deletions pkg/commands/netease.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
_ "net/http/pprof"
"strconv"

"github.com/anhoder/foxful-cli/model"
"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"
"github.com/mattn/go-runewidth"

tea "github.com/charmbracelet/bubbletea"
"github.com/gookit/gcli/v2"
)

Expand All @@ -31,18 +32,24 @@ func runPlayer(_ *gcli.Command, _ []string) error {
}

http.DefaultClient.Timeout = constants.AppHttpTimeout
neteaseModel := ui.NewNeteaseModel(configs.ConfigRegistry.StartupLoadingDuration)

var opts []tea.ProgramOption
if configs.ConfigRegistry.MainEnableMouseEvent {
opts = append(opts, tea.WithMouseCellMotion())
}
if configs.ConfigRegistry.MainAltScreen {
opts = append(opts, tea.WithAltScreen())
}
program := tea.ReplaceWithFoxfulRenderer(tea.NewProgram(neteaseModel, opts...))
neteaseModel.BindProgram(program)

_, err := program.Run()
return err
runewidth.DefaultCondition.EastAsianWidth = false

var opts = model.DefaultOptions()
configs.ConfigRegistry.FillToModelOpts(opts)

var (
netease = ui.NewNetease(model.NewApp(opts))
eventHandler = ui.NewEventHandler(netease)
)
netease.App.With(
model.WithHook(netease.InitHook, netease.CloseHook),
model.WithMainMenu(ui.NewMainMenu(netease), &model.MenuItem{Title: "网易云音乐"}),
func(options *model.Options) {
options.Components = append(options.Components, netease.Player())
options.KBControllers = append(options.KBControllers, eventHandler)
options.MouseControllers = append(options.MouseControllers, eventHandler)
},
)

return netease.Run()
}
30 changes: 30 additions & 0 deletions pkg/configs/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"strings"
"time"

"github.com/anhoder/foxful-cli/model"
tea "github.com/charmbracelet/bubbletea"
"github.com/go-musicfox/go-musicfox/pkg/constants"

"github.com/go-musicfox/netease-music/service"
Expand Down Expand Up @@ -66,6 +68,34 @@ type Registry struct {
PlayerMpdAddr string // mpd地址
}

func (r *Registry) FillToModelOpts(opts *model.Options) {
opts.StartupOptions.EnableStartup = r.StartupShow
opts.StartupOptions.LoadingDuration = r.StartupLoadingDuration
opts.StartupOptions.TickDuration = constants.StartupTickDuration
opts.StartupOptions.ProgressOutBounce = r.StartupProgressOutBounce
opts.StartupOptions.Welcome = r.StartupWelcome

opts.ProgressOptions.FirstFullChar = r.ProgressFirstFullChar
opts.ProgressOptions.FullChar = r.ProgressFullChar
opts.ProgressOptions.LastFullChar = r.ProgressLastFullChar
opts.ProgressOptions.FirstEmptyChar = r.ProgressFirstEmptyChar
opts.ProgressOptions.EmptyChar = r.ProgressEmptyChar
opts.ProgressOptions.LastEmptyChar = r.ProgressLastEmptyChar

opts.AppName = constants.AppName
opts.WhetherDisplayTitle = r.MainShowTitle
opts.LoadingText = r.MainLoadingText
opts.PrimaryColor = r.MainPrimaryColor
opts.DualColumn = r.MainDoubleColumn

if r.MainEnableMouseEvent {
opts.TeaOptions = append(opts.TeaOptions, tea.WithMouseCellMotion())
}
if r.MainAltScreen {
opts.TeaOptions = append(opts.TeaOptions, tea.WithAltScreen())
}
}

func NewRegistryWithDefault() *Registry {
registry := &Registry{
StartupShow: true,
Expand Down
15 changes: 9 additions & 6 deletions pkg/entry/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"fmt"
"log"

"github.com/anhoder/foxful-cli/util"
"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/go-musicfox/netease-music/util"
Expand All @@ -17,7 +17,7 @@ import (
func runCLI() {
log.SetOutput(utils.LogWriter())

app := gcli.NewApp()
var app = gcli.NewApp()
app.Name = constants.AppName
app.Version = constants.AppVersion
app.Description = constants.AppDescription
Expand All @@ -28,9 +28,12 @@ func runCLI() {
// 加载config
utils.LoadIniConfig()

logo := utils.GetAlphaAscii(app.Name)
randomColor := ui.GetPrimaryColor()
logoColorful := ui.SetFgStyle(logo, randomColor)
util.PrimaryColor = configs.ConfigRegistry.MainPrimaryColor
var (
logo = util.GetAlphaAscii(app.Name)
randomColor = util.GetPrimaryColor()
logoColorful = util.SetFgStyle(logo, randomColor)
)

gcli.AppHelpTemplate = fmt.Sprintf(constants.AppHelpTemplate, logoColorful)
app.Logo.Text = logoColorful
Expand All @@ -42,7 +45,7 @@ func runCLI() {
neteaseutil.EnableLocalVip = configs.ConfigRegistry.UNMEnableLocalVip
neteaseutil.UnlockSoundEffects = configs.ConfigRegistry.UNMUnlockSoundEffects

playerCommand := commands.NewPlayerCommand()
var playerCommand = commands.NewPlayerCommand()
app.Add(playerCommand)
app.Add(commands.NewConfigCommand())
app.DefaultCommand(playerCommand.Name)
Expand Down
Loading

0 comments on commit eac171b

Please sign in to comment.