strip-beats/app/menu.go

87 lines
1.5 KiB
Go
Raw Permalink Normal View History

2023-09-08 11:00:07 -05:00
package app
import (
"fmt"
2023-11-11 18:51:38 -06:00
"codeberg.org/danjones000/strip-beats/io/list"
2023-09-08 11:00:07 -05:00
)
func (st AppStep) Title() string {
mustpick := "You need to pick a file"
switch st {
case Pick:
2023-11-12 22:10:31 -06:00
return "Pick a new file"
2023-09-08 11:00:07 -05:00
case Watch:
if file == nil {
return mustpick
}
return fmt.Sprintf("Watch %s", file.ShortPath())
case Fade:
if file == nil {
return mustpick
}
return fmt.Sprintf("Trim and/or add fade to %s", file.ShortPath())
2023-09-23 21:57:56 -05:00
case Print:
if file == nil {
return mustpick
}
return fmt.Sprintf("Should we try to identify %s", file.ShortPath())
2023-11-12 22:10:31 -06:00
case Convert:
if file == nil {
return mustpick
}
return fmt.Sprintf("Convert %s?", file.ShortPath())
2023-09-08 11:00:07 -05:00
case Restart:
return "Forget current selection"
case Quit:
return "Quit"
default:
return ""
}
}
func (st AppStep) Text() string {
2023-09-23 21:57:56 -05:00
if st == Print {
return "Use fpcalc, AcousticId, and MusicBrainz to identify the song"
}
2023-09-08 11:00:07 -05:00
return ""
}
func (st AppStep) Rune() rune {
switch st {
case Pick:
return 'p'
case Watch:
return 'w'
case Fade:
return 'f'
case Restart:
return 'r'
2023-09-23 21:57:56 -05:00
case Print:
return 'a'
2023-11-12 22:10:31 -06:00
case Convert:
return 'c'
2023-09-08 11:00:07 -05:00
case Quit:
return 'q'
default:
return '0'
}
}
func (st AppStep) Selected() func() {
return nil
}
func mainMenu() AppStep {
var steps []list.Option
if file == nil {
steps = []list.Option{Pick, Quit}
} else {
2023-11-12 22:10:31 -06:00
steps = []list.Option{Pick, Watch, Fade, Print, Convert, Quit}
2023-09-08 11:00:07 -05:00
}
step := list.List("What would you like to do next?", steps, nil)
return step.(AppStep)
}