Add app.PickFileWithConf()

This commit is contained in:
Dan Jones 2023-09-04 15:36:32 -05:00
commit 871db79c19
2 changed files with 23 additions and 1 deletions

View file

@ -2,7 +2,10 @@ package app
import (
"codeberg.org/danjones000/strip-beats/files"
"codeberg.org/danjones000/strip-beats/input/boolean"
"codeberg.org/danjones000/strip-beats/media"
"fmt"
p "path"
)
var file *media.Probe
@ -18,6 +21,25 @@ func SetFile(path string) media.Probe {
return f
}
func PickFileWithConf() media.Probe {
var path string
var msg string
var base string
var dir string
good := false
for !good {
path = files.PickRandomFile()
base = p.Base(path)
dir = p.Dir(path)
dir = p.Base(dir)
msg = fmt.Sprintf("We've selected %s%s%s\nIs that ok?", dir, "/", base)
good = boolean.Choose(msg)
}
return SetFile(path)
}
func GetFile() media.Probe {
if file == nil {
return PickNewFile()