diff --git a/cmd/nowplaying.go b/cmd/nowplaying.go index 4974a39..69f64f0 100644 --- a/cmd/nowplaying.go +++ b/cmd/nowplaying.go @@ -13,7 +13,8 @@ var nowPlayingCmd = &cobra.Command{ Aliases: []string{"now"}, Short: "Shows song and artist of currently playing song", Long: `Shows song and artist of currently playing song, useful for scripting`, + Args: cobra.MatchAll(cobra.RangeArgs(0, 1)), Run: func(cmd *cobra.Command, args []string) { - commands.NowPlaying(ctx) + commands.NowPlaying(ctx, args) }, } diff --git a/src/commands/commands.go b/src/commands/commands.go index 0e3dc3d..479c46e 100644 --- a/src/commands/commands.go +++ b/src/commands/commands.go @@ -962,7 +962,18 @@ func (c *Commands) LinkContext(ctx *gctx.Context) (string, error) { return state.PlaybackContext.ExternalURLs["spotify"], nil } -func (c *Commands) NowPlaying(ctx *gctx.Context) error { +func (c *Commands) NowPlaying(ctx *gctx.Context, args []string) error { + if len(args) > 0 { + if args[0] == "force" { + current, err := c.Client().PlayerCurrentlyPlaying(ctx) + if err != nil { + return err + } + str := FormatSong(current) + fmt.Println(str) + return nil + } + } song, err := cache.DefaultCache().GetOrDo("now_playing", func() (string, error) { current, err := c.Client().PlayerCurrentlyPlaying(ctx) if err != nil {