🚧 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"
|
"fmt"
|
||||||
"os"
|
"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/input/boolean"
|
||||||
"codeberg.org/danjones000/strip-beats/media"
|
"codeberg.org/danjones000/strip-beats/media"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
@ -20,8 +20,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) {
|
||||||
file := files.PickRandomFile()
|
out := app.GetFile()
|
||||||
out := media.ProbeFile(file)
|
|
||||||
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?")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue