File tree 3 files changed +79
-0
lines changed
3 files changed +79
-0
lines changed Original file line number Diff line number Diff line change 1
1
build
2
+ /baton
Original file line number Diff line number Diff line change
1
+ package cmd
2
+
3
+ import (
4
+ "fmt"
5
+
6
+ "github.com/joshuathompson/baton/api"
7
+ "github.com/spf13/cobra"
8
+ )
9
+
10
+ func removeTrack (cmd * cobra.Command , args []string ) {
11
+ ctx , err := api .GetPlayerState (nil )
12
+
13
+ if err != nil {
14
+ fmt .Printf ("Couldn't get the player state. Is Spotify active on a device? Have you authenticated with the 'auth' command?\n " )
15
+ return
16
+ }
17
+
18
+ if ctx .Item == nil {
19
+ fmt .Printf ("Couldn't find information about the current status\n " )
20
+ return
21
+ }
22
+
23
+ err = api .RemoveSavedTrack (ctx .Item .ID )
24
+ if err != nil {
25
+ fmt .Printf ("Couldn't remove the track from saved. %s\n " , err )
26
+ return
27
+ }
28
+ }
29
+
30
+ func init () {
31
+ rootCmd .AddCommand (removeTrackCmd )
32
+ }
33
+
34
+ var removeTrackCmd = & cobra.Command {
35
+ Use : "remove" ,
36
+ Short : "Remove current playing track from saved" ,
37
+ Long : `Remove current playing track from saved` ,
38
+ Run : removeTrack ,
39
+ }
Original file line number Diff line number Diff line change
1
+ package cmd
2
+
3
+ import (
4
+ "fmt"
5
+
6
+ "github.com/joshuathompson/baton/api"
7
+ "github.com/spf13/cobra"
8
+ )
9
+
10
+ func saveTrack (cmd * cobra.Command , args []string ) {
11
+ ctx , err := api .GetPlayerState (nil )
12
+
13
+ if err != nil {
14
+ fmt .Printf ("Couldn't get the player state. Is Spotify active on a device? Have you authenticated with the 'auth' command?\n " )
15
+ return
16
+ }
17
+
18
+ if ctx .Item == nil {
19
+ fmt .Printf ("Couldn't find information about the current status\n " )
20
+ return
21
+ }
22
+
23
+ err = api .SaveTrack (ctx .Item .ID )
24
+ if err != nil {
25
+ fmt .Printf ("Couldn't save the track. %s\n " , err )
26
+ return
27
+ }
28
+ }
29
+
30
+ func init () {
31
+ rootCmd .AddCommand (saveTrackCmd )
32
+ }
33
+
34
+ var saveTrackCmd = & cobra.Command {
35
+ Use : "save" ,
36
+ Short : "Save current playing track" ,
37
+ Long : `Save current playing track` ,
38
+ Run : saveTrack ,
39
+ }
You can’t perform that action at this time.
0 commit comments