Skip to content

Commit

Permalink
add shell command
Browse files Browse the repository at this point in the history
  • Loading branch information
brianstrauch committed Dec 2, 2021
1 parent 3987d0e commit fb58de1
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 16 deletions.
6 changes: 6 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.17

require (
github.com/blang/semver v3.5.1+incompatible
github.com/brianstrauch/cobra-shell v0.1.0
github.com/brianstrauch/spotify v0.7.1
github.com/olekukonko/tablewriter v0.0.5
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2
Expand All @@ -14,6 +15,7 @@ require (
)

require (
github.com/c-bata/go-prompt v0.2.6 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/golang/protobuf v1.5.2 // indirect
Expand All @@ -23,9 +25,13 @@ require (
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mattn/go-colorable v0.1.7 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mattn/go-tty v0.0.3 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/pelletier/go-toml v1.9.3 // indirect
github.com/pkg/term v1.2.0-beta.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
Expand Down
22 changes: 22 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/brianstrauch/cobra-shell v0.1.0 h1:eT+Km73w6443XjXyKRdb6ruMNnmllgHt2Vh1Uxyvhuw=
github.com/brianstrauch/cobra-shell v0.1.0/go.mod h1:LN1dyeUALI56MuTodOvqV8EA0fwy7eRnrvBir6fw1Mo=
github.com/brianstrauch/spotify v0.7.1 h1:tkRH07ctLTJ8zr+0HQQYVyVxbGV/FP9xgzy8Ef/Sbew=
github.com/brianstrauch/spotify v0.7.1/go.mod h1:KGmim5eCKSgu5y+jOrJPa8fxTFfy0GzeidodVnjGnUM=
github.com/c-bata/go-prompt v0.2.6 h1:POP+nrHE+DfLYx370bedwNhsqmpCUynWPxuHi0C5vZI=
github.com/c-bata/go-prompt v0.2.6/go.mod h1:/LMAke8wD2FsNu9EXNdHxNLbd9MedkPnCdfpU9wwHfY=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
Expand Down Expand Up @@ -194,9 +198,19 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw=
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-tty v0.0.3 h1:5OfyWorkyO7xP52Mq7tB36ajHDG5OHrmBGIS/DtakQI=
github.com/mattn/go-tty v0.0.3/go.mod h1:ihxohKRERHTVzN+aSVRwACLCeqIoZAWpoICkkvrWyR0=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
Expand All @@ -222,6 +236,8 @@ github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 h1:acNfDZXmm28D2Yg/c3A
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
github.com/pkg/term v1.2.0-beta.2 h1:L3y/h2jkuBVFdWiJvNfYfKmzcCnILw7mJWm2JQuMppw=
github.com/pkg/term v1.2.0-beta.2/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
Expand Down Expand Up @@ -395,6 +411,7 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -404,10 +421,13 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -421,6 +441,8 @@ golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200918174421-af09f7315aff/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
2 changes: 1 addition & 1 deletion internal/back/back.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func NewCommand() *cobra.Command {
return &cobra.Command{
Use: "back",
Aliases: []string{"b"},
Short: "skip to previous song",
Short: "Skip to previous song.",
RunE: func(cmd *cobra.Command, _ []string) error {
api, err := internal.Authenticate()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const RedirectURI = "http://localhost:1024/callback"
func NewCommand() *cobra.Command {
return &cobra.Command{
Use: "login",
Short: "log in to spotify",
Short: "Log in to Spotify.",
RunE: func(cmd *cobra.Command, _ []string) error {
token, err := login()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/next/next.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func NewCommand() *cobra.Command {
return &cobra.Command{
Use: "next",
Aliases: []string{"n"},
Short: "skip to next song",
Short: "Skip to next song.",
RunE: func(cmd *cobra.Command, _ []string) error {
api, err := internal.Authenticate()
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions internal/p/p.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import (

func NewCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "p [song]",
// Keep hidden, since this command is an alias.
Hidden: true,
Use: "p [song]",
Hidden: true, // Keep hidden, since this command is an alias.
RunE: func(cmd *cobra.Command, args []string) error {
api, err := internal.Authenticate()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/pause/pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func NewCommand() *cobra.Command {
return &cobra.Command{
Use: "pause",
Short: "pause music",
Short: "Pause music.",
RunE: func(cmd *cobra.Command, _ []string) error {
api, err := internal.Authenticate()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/play/play.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
func NewCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "play [song]",
Short: "play current song, or a specific song",
Short: "Play current song, or a specific song.",
RunE: func(cmd *cobra.Command, args []string) error {
api, err := internal.Authenticate()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/playlist/playlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
func NewCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "playlist",
Short: "manage playlists",
Short: "Manage playlists.",
}

cmd.AddCommand(NewListCommand())
Expand Down
2 changes: 1 addition & 1 deletion internal/queue/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func NewCommand() *cobra.Command {
return &cobra.Command{
Use: "queue song",
Aliases: []string{"q"},
Short: "queue a specific song",
Short: "Queue a specific song.",
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
api, err := internal.Authenticate()
Expand Down
2 changes: 1 addition & 1 deletion internal/repeat/repeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
func NewCommand() *cobra.Command {
return &cobra.Command{
Use: "repeat [on|off|track]",
Short: "set repeat to on, off, or track",
Short: "Set repeat to on, off, or track.",
Args: cobra.ExactValidArgs(1),
ValidArgs: []string{"on", "off", "track"},
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/save/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func NewCommand() *cobra.Command {
return &cobra.Command{
Use: "save",
Short: "save the current song",
Short: "Save the current song.",
RunE: func(cmd *cobra.Command, _ []string) error {
api, err := internal.Authenticate()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/shuffle/shuffle.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func NewCommand() *cobra.Command {
return &cobra.Command{
Use: "shuffle [on|off]",
Short: "turn shuffle on or off",
Short: "Turn shuffle on or off.",
Args: cobra.ExactValidArgs(1),
ValidArgs: []string{"on", "off"},
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewCommand() *cobra.Command {
return &cobra.Command{
Use: "status",
Aliases: []string{"s"},
Short: "show the current song or episode",
Short: "Show the current song or episode.",
RunE: func(cmd *cobra.Command, _ []string) error {
api, err := internal.Authenticate()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/unsave/unsave.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func NewCommand() *cobra.Command {
return &cobra.Command{
Use: "unsave",
Short: "unsave the current song",
Short: "Unsave the current song.",
RunE: func(cmd *cobra.Command, _ []string) error {
api, err := internal.Authenticate()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const repo = "brianstrauch/spotify-cli"
func NewCommand() *cobra.Command {
return &cobra.Command{
Use: "update",
Short: "update CLI to the latest version",
Short: "Update CLI to the latest version.",
RunE: func(cmd *cobra.Command, _ []string) error {
isUpdated, err := IsUpdated(cmd)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"time"

shell "github.com/brianstrauch/cobra-shell"
"github.com/spf13/cobra"
"github.com/spf13/viper"

Expand Down Expand Up @@ -50,6 +51,7 @@ func main() {
root.AddCommand(queue.NewCommand())
root.AddCommand(repeat.NewCommand())
root.AddCommand(save.NewCommand())
root.AddCommand(shell.New(root))
root.AddCommand(shuffle.NewCommand())
root.AddCommand(status.NewCommand())
root.AddCommand(unsave.NewCommand())
Expand Down

0 comments on commit fb58de1

Please sign in to comment.