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 ( import (
"codeberg.org/danjones000/strip-beats/files" "codeberg.org/danjones000/strip-beats/files"
"codeberg.org/danjones000/strip-beats/input/boolean"
"codeberg.org/danjones000/strip-beats/media" "codeberg.org/danjones000/strip-beats/media"
"fmt"
p "path"
) )
var file *media.Probe var file *media.Probe
@ -18,6 +21,25 @@ func SetFile(path string) media.Probe {
return f 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 { func GetFile() media.Probe {
if file == nil { if file == nil {
return PickNewFile() return PickNewFile()

View file

@ -19,7 +19,7 @@ var rootCmd = &cobra.Command{
// Uncomment the following line if your bare application // Uncomment the following line if your bare application
// has an action associated with it: // has an action associated with it:
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
out := app.GetFile() out := app.PickFileWithConf()
fmt.Printf("%+v\n", out) fmt.Printf("%+v\n", out)
// media.Watch(out.Format.Path) // media.Watch(out.Format.Path)
show := boolean.Choose("Show stream?") show := boolean.Choose("Show stream?")