🚧 App package to hold app state
This commit is contained in:
parent
433f49e9e0
commit
d91fc4b9ec
2 changed files with 29 additions and 3 deletions
27
app/choose.go
Normal file
27
app/choose.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package app
|
||||
|
||||
import (
|
||||
"codeberg.org/danjones000/strip-beats/files"
|
||||
"codeberg.org/danjones000/strip-beats/media"
|
||||
)
|
||||
|
||||
var file *media.Probe
|
||||
|
||||
func PickNewFile() media.Probe {
|
||||
path := files.PickRandomFile()
|
||||
f := media.ProbeFile(path)
|
||||
file = &f
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
func GetFile() media.Probe {
|
||||
if file == nil {
|
||||
return PickNewFile()
|
||||
}
|
||||
return *file
|
||||
}
|
||||
|
||||
func ForgetFile() {
|
||||
file = nil
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"codeberg.org/danjones000/strip-beats/files"
|
||||
"codeberg.org/danjones000/strip-beats/app"
|
||||
"codeberg.org/danjones000/strip-beats/input/boolean"
|
||||
"codeberg.org/danjones000/strip-beats/media"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -20,8 +20,7 @@ var rootCmd = &cobra.Command{
|
|||
// Uncomment the following line if your bare application
|
||||
// has an action associated with it:
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
file := files.PickRandomFile()
|
||||
out := media.ProbeFile(file)
|
||||
out := app.GetFile()
|
||||
fmt.Printf("%+v\n", out)
|
||||
// media.Watch(out.Format.Path)
|
||||
show := boolean.Choose("Show stream?")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue