🚧 Step through app
This commit is contained in:
parent
a41880dad5
commit
c941ed3302
3 changed files with 72 additions and 24 deletions
|
|
@ -39,6 +39,12 @@ func PickFileWithConf() media.Probe {
|
|||
path = files.PickRandomFile()
|
||||
msg = fmt.Sprintf("We've selected %s\nIs that ok?", getShortPath(path))
|
||||
good = boolean.Choose(msg)
|
||||
if !good {
|
||||
good = boolean.Choose("Would you like to quit?")
|
||||
if good {
|
||||
return media.Probe{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SetFile(path)
|
||||
|
|
@ -58,7 +64,7 @@ func GetTmpFile() media.Probe {
|
|||
return *tmpfile
|
||||
}
|
||||
|
||||
func BailOut() {
|
||||
func PickAgain() {
|
||||
if tmpfile != nil {
|
||||
os.Remove(tmpfile.Format.Path)
|
||||
}
|
||||
|
|
@ -73,7 +79,7 @@ func Finish() {
|
|||
panic(err)
|
||||
}
|
||||
}
|
||||
BailOut()
|
||||
PickAgain()
|
||||
}
|
||||
|
||||
func getShortPath(path string) string {
|
||||
|
|
|
|||
41
app/run.go
Normal file
41
app/run.go
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"codeberg.org/danjones000/strip-beats/media"
|
||||
)
|
||||
|
||||
type AppStep int
|
||||
|
||||
const (
|
||||
Pick AppStep = iota
|
||||
Watch
|
||||
Restart
|
||||
Quit
|
||||
)
|
||||
|
||||
func quit() {
|
||||
PickAgain()
|
||||
fmt.Println("Goodbye!")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func Run(step AppStep) {
|
||||
for step < Quit {
|
||||
switch step {
|
||||
case Pick:
|
||||
PickAgain()
|
||||
PickFileWithConf()
|
||||
if file == nil {
|
||||
quit()
|
||||
}
|
||||
case Watch:
|
||||
media.Watch(file.Format.Path)
|
||||
case Quit:
|
||||
quit()
|
||||
}
|
||||
step = (step + 1) % Restart
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue