diff --git a/internal/device/device.go b/internal/device/device.go deleted file mode 100644 index e051c9e..0000000 --- a/internal/device/device.go +++ /dev/null @@ -1,16 +0,0 @@ -package device - -import ( - "github.com/spf13/cobra" -) - -func NewCommand() *cobra.Command { - cmd := &cobra.Command{ - Use: "device", - Short: "manage devices", - } - - cmd.AddCommand(NewListCommand()) - - return cmd -} diff --git a/internal/device/list.go b/internal/device/list.go deleted file mode 100644 index 55dda7a..0000000 --- a/internal/device/list.go +++ /dev/null @@ -1,57 +0,0 @@ -package device - -import ( - "errors" - "fmt" - "spotify/internal" - "strings" - - "github.com/olekukonko/tablewriter" - "github.com/spf13/cobra" -) - -func NewListCommand() *cobra.Command { - return &cobra.Command{ - Use: "list", - Short: "list your devices", - RunE: func(cmd *cobra.Command, args []string) error { - api, err := internal.Authenticate() - if err != nil { - return err - } - - list, err := List(api) - if err != nil { - return err - } - - fmt.Print(list) - return nil - }, - } -} - -func List(api internal.APIInterface) (string, error) { - devices, err := api.GetDevices() - if err != nil { - return "", err - } - - if len(devices) == 0 { - return "", errors.New(internal.ErrNoDevices) - } - - output := new(strings.Builder) - - table := tablewriter.NewWriter(output) - table.SetBorder(false) - - table.SetHeader([]string{"ID", "Device"}) - - for _, device := range devices { - table.Append([]string{device.ID, device.Name}) - } - table.Render() - - return output.String(), nil -} diff --git a/main.go b/main.go index 5d6ec40..343a990 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,6 @@ import ( "github.com/spf13/viper" "spotify/internal/back" - "spotify/internal/device" "spotify/internal/login" "spotify/internal/next" "spotify/internal/p" @@ -42,7 +41,6 @@ func main() { } root.AddCommand(back.NewCommand()) - root.AddCommand(device.NewCommand()) root.AddCommand(login.NewCommand()) root.AddCommand(next.NewCommand()) root.AddCommand(p.NewCommand())