Skip to content

Commit fb58de1

Browse files
committed
add shell command
1 parent 3987d0e commit fb58de1

File tree

17 files changed

+45
-16
lines changed

17 files changed

+45
-16
lines changed

go.mod

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.17
44

55
require (
66
github.com/blang/semver v3.5.1+incompatible
7+
github.com/brianstrauch/cobra-shell v0.1.0
78
github.com/brianstrauch/spotify v0.7.1
89
github.com/olekukonko/tablewriter v0.0.5
910
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2
@@ -14,6 +15,7 @@ require (
1415
)
1516

1617
require (
18+
github.com/c-bata/go-prompt v0.2.6 // indirect
1719
github.com/davecgh/go-spew v1.1.1 // indirect
1820
github.com/fsnotify/fsnotify v1.4.9 // indirect
1921
github.com/golang/protobuf v1.5.2 // indirect
@@ -23,9 +25,13 @@ require (
2325
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf // indirect
2426
github.com/inconshreveable/mousetrap v1.0.0 // indirect
2527
github.com/magiconair/properties v1.8.5 // indirect
28+
github.com/mattn/go-colorable v0.1.7 // indirect
29+
github.com/mattn/go-isatty v0.0.12 // indirect
2630
github.com/mattn/go-runewidth v0.0.9 // indirect
31+
github.com/mattn/go-tty v0.0.3 // indirect
2732
github.com/mitchellh/mapstructure v1.4.1 // indirect
2833
github.com/pelletier/go-toml v1.9.3 // indirect
34+
github.com/pkg/term v1.2.0-beta.2 // indirect
2935
github.com/pmezard/go-difflib v1.0.0 // indirect
3036
github.com/spf13/afero v1.6.0 // indirect
3137
github.com/spf13/cast v1.3.1 // indirect

go.sum

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
4747
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
4848
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
4949
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
50+
github.com/brianstrauch/cobra-shell v0.1.0 h1:eT+Km73w6443XjXyKRdb6ruMNnmllgHt2Vh1Uxyvhuw=
51+
github.com/brianstrauch/cobra-shell v0.1.0/go.mod h1:LN1dyeUALI56MuTodOvqV8EA0fwy7eRnrvBir6fw1Mo=
5052
github.com/brianstrauch/spotify v0.7.1 h1:tkRH07ctLTJ8zr+0HQQYVyVxbGV/FP9xgzy8Ef/Sbew=
5153
github.com/brianstrauch/spotify v0.7.1/go.mod h1:KGmim5eCKSgu5y+jOrJPa8fxTFfy0GzeidodVnjGnUM=
54+
github.com/c-bata/go-prompt v0.2.6 h1:POP+nrHE+DfLYx370bedwNhsqmpCUynWPxuHi0C5vZI=
55+
github.com/c-bata/go-prompt v0.2.6/go.mod h1:/LMAke8wD2FsNu9EXNdHxNLbd9MedkPnCdfpU9wwHfY=
5256
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
5357
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
5458
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
@@ -194,9 +198,19 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
194198
github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
195199
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
196200
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
201+
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
202+
github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw=
203+
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
197204
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
205+
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
206+
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
207+
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
208+
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
209+
github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
198210
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
199211
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
212+
github.com/mattn/go-tty v0.0.3 h1:5OfyWorkyO7xP52Mq7tB36ajHDG5OHrmBGIS/DtakQI=
213+
github.com/mattn/go-tty v0.0.3/go.mod h1:ihxohKRERHTVzN+aSVRwACLCeqIoZAWpoICkkvrWyR0=
200214
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
201215
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
202216
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
@@ -222,6 +236,8 @@ github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 h1:acNfDZXmm28D2Yg/c3A
222236
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
223237
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
224238
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
239+
github.com/pkg/term v1.2.0-beta.2 h1:L3y/h2jkuBVFdWiJvNfYfKmzcCnILw7mJWm2JQuMppw=
240+
github.com/pkg/term v1.2.0-beta.2/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw=
225241
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
226242
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
227243
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
@@ -395,6 +411,7 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h
395411
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
396412
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
397413
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
414+
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
398415
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
399416
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
400417
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -404,10 +421,13 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w
404421
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
405422
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
406423
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
424+
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
407425
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
426+
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
408427
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
409428
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
410429
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
430+
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
411431
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
412432
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
413433
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -421,6 +441,8 @@ golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7w
421441
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
422442
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
423443
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
444+
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
445+
golang.org/x/sys v0.0.0-20200918174421-af09f7315aff/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
424446
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
425447
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
426448
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

internal/back/back.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func NewCommand() *cobra.Command {
1313
return &cobra.Command{
1414
Use: "back",
1515
Aliases: []string{"b"},
16-
Short: "skip to previous song",
16+
Short: "Skip to previous song.",
1717
RunE: func(cmd *cobra.Command, _ []string) error {
1818
api, err := internal.Authenticate()
1919
if err != nil {

internal/login/login.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const RedirectURI = "http://localhost:1024/callback"
2727
func NewCommand() *cobra.Command {
2828
return &cobra.Command{
2929
Use: "login",
30-
Short: "log in to spotify",
30+
Short: "Log in to Spotify.",
3131
RunE: func(cmd *cobra.Command, _ []string) error {
3232
token, err := login()
3333
if err != nil {

internal/next/next.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func NewCommand() *cobra.Command {
1313
return &cobra.Command{
1414
Use: "next",
1515
Aliases: []string{"n"},
16-
Short: "skip to next song",
16+
Short: "Skip to next song.",
1717
RunE: func(cmd *cobra.Command, _ []string) error {
1818
api, err := internal.Authenticate()
1919
if err != nil {

internal/p/p.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ import (
1212

1313
func NewCommand() *cobra.Command {
1414
cmd := &cobra.Command{
15-
Use: "p [song]",
16-
// Keep hidden, since this command is an alias.
17-
Hidden: true,
15+
Use: "p [song]",
16+
Hidden: true, // Keep hidden, since this command is an alias.
1817
RunE: func(cmd *cobra.Command, args []string) error {
1918
api, err := internal.Authenticate()
2019
if err != nil {

internal/pause/pause.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
func NewCommand() *cobra.Command {
1313
return &cobra.Command{
1414
Use: "pause",
15-
Short: "pause music",
15+
Short: "Pause music.",
1616
RunE: func(cmd *cobra.Command, _ []string) error {
1717
api, err := internal.Authenticate()
1818
if err != nil {

internal/play/play.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
func NewCommand() *cobra.Command {
1515
cmd := &cobra.Command{
1616
Use: "play [song]",
17-
Short: "play current song, or a specific song",
17+
Short: "Play current song, or a specific song.",
1818
RunE: func(cmd *cobra.Command, args []string) error {
1919
api, err := internal.Authenticate()
2020
if err != nil {

internal/playlist/playlist.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
func NewCommand() *cobra.Command {
88
cmd := &cobra.Command{
99
Use: "playlist",
10-
Short: "manage playlists",
10+
Short: "Manage playlists.",
1111
}
1212

1313
cmd.AddCommand(NewListCommand())

internal/queue/queue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func NewCommand() *cobra.Command {
1313
return &cobra.Command{
1414
Use: "queue song",
1515
Aliases: []string{"q"},
16-
Short: "queue a specific song",
16+
Short: "Queue a specific song.",
1717
Args: cobra.MinimumNArgs(1),
1818
RunE: func(cmd *cobra.Command, args []string) error {
1919
api, err := internal.Authenticate()

internal/repeat/repeat.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const (
1616
func NewCommand() *cobra.Command {
1717
return &cobra.Command{
1818
Use: "repeat [on|off|track]",
19-
Short: "set repeat to on, off, or track",
19+
Short: "Set repeat to on, off, or track.",
2020
Args: cobra.ExactValidArgs(1),
2121
ValidArgs: []string{"on", "off", "track"},
2222
RunE: func(cmd *cobra.Command, args []string) error {

internal/save/save.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
func NewCommand() *cobra.Command {
1111
return &cobra.Command{
1212
Use: "save",
13-
Short: "save the current song",
13+
Short: "Save the current song.",
1414
RunE: func(cmd *cobra.Command, _ []string) error {
1515
api, err := internal.Authenticate()
1616
if err != nil {

internal/shuffle/shuffle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
func NewCommand() *cobra.Command {
1111
return &cobra.Command{
1212
Use: "shuffle [on|off]",
13-
Short: "turn shuffle on or off",
13+
Short: "Turn shuffle on or off.",
1414
Args: cobra.ExactValidArgs(1),
1515
ValidArgs: []string{"on", "off"},
1616
RunE: func(cmd *cobra.Command, args []string) error {

internal/status/status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func NewCommand() *cobra.Command {
2121
return &cobra.Command{
2222
Use: "status",
2323
Aliases: []string{"s"},
24-
Short: "show the current song or episode",
24+
Short: "Show the current song or episode.",
2525
RunE: func(cmd *cobra.Command, _ []string) error {
2626
api, err := internal.Authenticate()
2727
if err != nil {

internal/unsave/unsave.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
func NewCommand() *cobra.Command {
1111
return &cobra.Command{
1212
Use: "unsave",
13-
Short: "unsave the current song",
13+
Short: "Unsave the current song.",
1414
RunE: func(cmd *cobra.Command, _ []string) error {
1515
api, err := internal.Authenticate()
1616
if err != nil {

internal/update/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const repo = "brianstrauch/spotify-cli"
1515
func NewCommand() *cobra.Command {
1616
return &cobra.Command{
1717
Use: "update",
18-
Short: "update CLI to the latest version",
18+
Short: "Update CLI to the latest version.",
1919
RunE: func(cmd *cobra.Command, _ []string) error {
2020
isUpdated, err := IsUpdated(cmd)
2121
if err != nil {

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"time"
55

6+
shell "github.com/brianstrauch/cobra-shell"
67
"github.com/spf13/cobra"
78
"github.com/spf13/viper"
89

@@ -50,6 +51,7 @@ func main() {
5051
root.AddCommand(queue.NewCommand())
5152
root.AddCommand(repeat.NewCommand())
5253
root.AddCommand(save.NewCommand())
54+
root.AddCommand(shell.New(root))
5355
root.AddCommand(shuffle.NewCommand())
5456
root.AddCommand(status.NewCommand())
5557
root.AddCommand(unsave.NewCommand())

0 commit comments

Comments
 (0)