diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2416d76774..a17beebb92 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -95,7 +95,7 @@ Follow the steps outlined in the [documentation](https://spicetify.app/docs/deve ### Improving The Documentation -To improve the [documentation](https://spicetify.app/docs/getting-started), navigate to the documentation [repository](https://github.com/spicetify/spicetify-docs). +To improve the [documentation](https://spicetify.app/docs/getting-started), navigate to the documentation [repository](https://github.com/spicetify/docs). ### Commit Message Format diff --git a/go.mod b/go.mod index e7f29bf6cb..6dcc8725ca 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.24.2 require ( github.com/go-ini/ini v1.67.0 github.com/mattn/go-colorable v0.1.14 - github.com/pterm/pterm v0.12.81 + github.com/pterm/pterm v0.12.80 golang.org/x/net v0.43.0 golang.org/x/sys v0.35.0 ) diff --git a/go.sum b/go.sum index 981f9e6227..4248d6efe7 100644 --- a/go.sum +++ b/go.sum @@ -54,8 +54,8 @@ github.com/pterm/pterm v0.12.31/go.mod h1:32ZAWZVXD7ZfG0s8qqHXePte42kdz8ECtRyEej github.com/pterm/pterm v0.12.33/go.mod h1:x+h2uL+n7CP/rel9+bImHD5lF3nM9vJj80k9ybiiTTE= github.com/pterm/pterm v0.12.36/go.mod h1:NjiL09hFhT/vWjQHSj1athJpx6H8cjpHXNAK5bUw8T8= github.com/pterm/pterm v0.12.40/go.mod h1:ffwPLwlbXxP+rxT0GsgDTzS3y3rmpAO1NMjUkGTYf8s= -github.com/pterm/pterm v0.12.81 h1:ju+j5I2++FO1jBKMmscgh5h5DPFDFMB7epEjSoKehKA= -github.com/pterm/pterm v0.12.81/go.mod h1:TyuyrPjnxfwP+ccJdBTeWHtd/e0ybQHkOS/TakajZCw= +github.com/pterm/pterm v0.12.80 h1:mM55B+GnKUnLMUSqhdINe4s6tOuVQIetQ3my8JGyAIg= +github.com/pterm/pterm v0.12.80/go.mod h1:c6DeF9bSnOSeFPZlfs4ZRAFcf5SCoTwvwQ5xaKGQlHo= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= diff --git a/spicetify.go b/spicetify.go index a93fc0ea05..4c055cb188 100644 --- a/spicetify.go +++ b/spicetify.go @@ -2,7 +2,6 @@ package main import ( "errors" - "fmt" "io" "log" "os" @@ -14,6 +13,7 @@ import ( "sync" colorable "github.com/mattn/go-colorable" + "github.com/pterm/pterm" "github.com/spicetify/cli/src/cmd" spotifystatus "github.com/spicetify/cli/src/status/spotify" "github.com/spicetify/cli/src/utils" @@ -53,8 +53,8 @@ func init() { // Separates flags and commands for _, v := range os.Args[1:] { - if len(v) > 0 && v[0] == '-' && v != "-1" { - if v[1] != '-' && len(v) > 2 { + if len(v) > 0 && v[0] == '-' { + if len(v) > 2 && v[1] != '-' { for _, char := range v[1:] { flags = append(flags, "-"+string(char)) } @@ -71,7 +71,7 @@ func init() { case "--bypass-admin": bypassAdminCheck = true case "-c", "--config": - fmt.Println(cmd.GetConfigPath()) + log.Println(cmd.GetConfigPath()) os.Exit(0) case "-h", "--help": kind := "" @@ -86,7 +86,7 @@ func init() { os.Exit(0) case "-v", "--version": - fmt.Println(version) + log.Println(version) os.Exit(0) case "-e", "--extension": extensionFocus = true @@ -112,14 +112,14 @@ func init() { if quiet { log.SetOutput(io.Discard) os.Stdout = nil + pterm.DisableOutput() } if isAdmin.Check(bypassAdminCheck) { - utils.PrintError("Spicetify should not be run with administrator/root privileges") - utils.PrintError("Running as admin can cause Spotify to show a black/blank window after applying spicetify") + utils.PrintError("Spicetify should NOT be run with administrator or root privileges") + utils.PrintError("Doing so can cause Spotify to show a black/blank window after applying!") utils.PrintError("This happens because Spotify (running as a normal user) can't access files modified with admin privileges") - utils.PrintInfo("If you understand the risks and need to continue anyway, you can use the '--bypass-admin' flag.") - utils.PrintInfo("Spicetify is now exiting...") + utils.PrintInfo("If you understand the risks and need to continue, you can use the '--bypass-admin' flag.") os.Exit(1) } @@ -291,12 +291,14 @@ func main() { spotStat := spotifystatus.Get(spotifyPath) if spotStat.IsBackupable() { - utils.PrintNote("spicetify is already up-to-date! If you ran this command because spicetify disappeared after Spotify updated, we'll attempt to fix it for you right now.") - cmd.Backup(version) + utils.PrintNote("spicetify is up-to-date! If you ran this because spicetify disappeared after Spotify updated, we'll attempt to fix it for you right now.") + cmd.Backup(version, true) cmd.CheckStates() cmd.InitSetting() cmd.Apply(version) - restartSpotify() + if !noRestart { + cmd.SpotifyRestart() + } } return @@ -308,7 +310,7 @@ func main() { for _, v := range commands { switch v { case "backup": - cmd.Backup(version) + cmd.Backup(version, slices.Contains(commands, "apply")) case "clear": cmd.Clear() @@ -317,7 +319,6 @@ func main() { cmd.CheckStates() cmd.InitSetting() cmd.Apply(version) - restartSpotify() case "refresh": cmd.CheckStates() @@ -332,30 +333,24 @@ func main() { case "restore": cmd.Restore() - restartSpotify() case "enable-devtools": - cmd.SetDevTools() - cmd.EvalSpotifyRestart(true) + cmd.EnableDevTools() case "restart": - cmd.EvalSpotifyRestart(false) + cmd.SpotifyRestart() case "auto": cmd.Auto(version) - cmd.EvalSpotifyRestart(true) default: - utils.PrintError(`Command "` + v + `" not found.`) - utils.PrintInfo(`Run "spicetify -h" for list of valid commands.`) - os.Exit(1) + utils.Fatal(errors.New(`Command "` + v + `" not found. +Run "spicetify -h" for a list of valid commands.`)) } } -} -func restartSpotify() { - if !noRestart { - cmd.EvalSpotifyRestart(false) + if !noRestart && !slices.Contains(commands, "restart") { + cmd.SpotifyRestart() } } @@ -367,34 +362,35 @@ func help() { utils.Bold("DESCRIPTION") + "\n" + "Customize Spotify client UI and functionality\n\n" + utils.Bold("CHAINABLE COMMANDS") + ` -backup Start backup and preprocessing app files. +backup Start backup and preprocessing of app files. apply Apply customization. refresh Refresh the theme's CSS, JS, colors, and assets. - Use with flag "-e" to update extensions. + Use with flag "-e" to update extensions or with flag "-a" to update custom apps. restore Restore Spotify to original state. clear Clear current backup files. enable-devtools Enable Spotify's developer tools. - Press Ctrl + Shift + I (Windows/Linux) or Cmd + Option + I (macOS) in the Spotify client to start using. + Press Ctrl + Shift + I (Windows/Linux) or Cmd + Option + I (macOS) in the Spotify client to open. watch Enter watch mode. To update on change, use with any combination of the following flags: "-e" (for extensions), "-a" (for custom apps), "-s" (for the active theme; color.ini, user.css, theme.js, and assets) - "-l" (for extensions, custom apps, and active theme) + "-l" (for all of the above) restart Restart Spotify client. ` + utils.Bold("NON-CHAINABLE COMMANDS") + ` -spotify-updates Blocks Spotify updates. Patches spotify executable. Accepts "block" or "unblock" as parameter. +spotify-updates Block Spotify updates by patching spotify executable. + Accept "block" or "unblock" as the parameter. -path Prints path of Spotify's executable, userdata, and more. +path Print path of Spotify's executable, userdata, and more. 1. Print executable path: spicetify path @@ -407,7 +403,7 @@ path Prints path of Spotify's executable, userdata, and more. 4. Toggle focus with flags: spicetify path