cmd

package
v0.0.0-...-33edafc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "mousiki",
	Short: "A command-line pandora client",
	Long:  "A command-line pandora client based off of pianobar",
	Args:  cobra.NoArgs,
	RunE: func(_ *cobra.Command, _ []string) error {
		p := api.NewClient()

		un := viper.GetString("username")
		pw := viper.GetString("password")

		if pw == "" {
			fmt.Print("Password: ")
			raw, _ := terminal.ReadPassword(int(os.Stdin.Fd()))
			pw = string(raw)

			if len(pw) < 8 {
				return fmt.Errorf("got bad password: %s (hex: %s)", pw, hex.EncodeToString(raw))
			}

			fmt.Println()
		}

		if pw == "" {
			logrus.Fatal("No password provided")
		}

		if err := p.LegacyLogin(un, pw); err != nil {
			return err
		}

		player, err := audio.NewBeepFFmpegPipeline()
		if err != nil {
			return err
		}

		defer func() {
			_ = player.Close()
		}()

		ctx, cancel := context.WithCancel(context.Background())
		defer cancel()

		controller := mousiki.NewStationController(p, player)

		app := ui.New(ctx, cancel, player, controller)
		return app.Run()
	},
}

Functions

func Exec

func Exec()

func MarkFlagRequired

func MarkFlagRequired(cmd *cobra.Command, name string)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL