🚧 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()
|
path = files.PickRandomFile()
|
||||||
msg = fmt.Sprintf("We've selected %s\nIs that ok?", getShortPath(path))
|
msg = fmt.Sprintf("We've selected %s\nIs that ok?", getShortPath(path))
|
||||||
good = boolean.Choose(msg)
|
good = boolean.Choose(msg)
|
||||||
|
if !good {
|
||||||
|
good = boolean.Choose("Would you like to quit?")
|
||||||
|
if good {
|
||||||
|
return media.Probe{}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SetFile(path)
|
return SetFile(path)
|
||||||
|
|
@ -58,7 +64,7 @@ func GetTmpFile() media.Probe {
|
||||||
return *tmpfile
|
return *tmpfile
|
||||||
}
|
}
|
||||||
|
|
||||||
func BailOut() {
|
func PickAgain() {
|
||||||
if tmpfile != nil {
|
if tmpfile != nil {
|
||||||
os.Remove(tmpfile.Format.Path)
|
os.Remove(tmpfile.Format.Path)
|
||||||
}
|
}
|
||||||
|
|
@ -73,7 +79,7 @@ func Finish() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BailOut()
|
PickAgain()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getShortPath(path string) string {
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
45
cmd/root.go
45
cmd/root.go
|
|
@ -4,12 +4,12 @@ Copyright © 2023 NAME HERE <EMAIL ADDRESS>
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
// "fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"codeberg.org/danjones000/strip-beats/app"
|
"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/input/list"
|
// "codeberg.org/danjones000/strip-beats/input/list"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -20,27 +20,28 @@ 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) {
|
||||||
opt := list.List([]list.Option{
|
app.Run(0)
|
||||||
list.SimpleItem("Yes", "", 'y'),
|
|
||||||
list.SimpleItem("No", "", 'n'),
|
|
||||||
list.SimpleItem("Maybe", "perhaps", 'm'),
|
|
||||||
}, nil)
|
|
||||||
fmt.Printf("%+v\n", opt)
|
|
||||||
// out := app.PickFileWithConf()
|
|
||||||
out := app.SetFile("/home/drj/nothing.mkv")
|
|
||||||
fmt.Println("first", out.Format.Path)
|
|
||||||
// tmp, _ := os.CreateTemp("", "audio.*.mka")
|
|
||||||
// defer os.Remove(tmp.Name())
|
|
||||||
// fmt.Println("temp", tmp.Name())
|
|
||||||
app.Finish()
|
|
||||||
/*
|
/*
|
||||||
fmt.Printf("%+v\n", out)
|
opt := list.List([]list.Option{
|
||||||
// media.Watch(out.Format.Path)
|
list.SimpleItem("Yes", "", 'y'),
|
||||||
show := boolean.Choose("Show stream?")
|
list.SimpleItem("No", "", 'n'),
|
||||||
if show {
|
list.SimpleItem("Maybe", "perhaps", 'm'),
|
||||||
stream := out.WantedAudioStream()
|
}, nil)
|
||||||
fmt.Printf("Stream %d of %s: %+v\n", stream.Index, out.Format.Path, stream)
|
fmt.Printf("%+v\n", opt)
|
||||||
}
|
// out := app.PickFileWithConf()
|
||||||
|
out := app.SetFile("/home/drj/nothing.mkv")
|
||||||
|
fmt.Println("first", out.Format.Path)
|
||||||
|
// tmp, _ := os.CreateTemp("", "audio.*.mka")
|
||||||
|
// defer os.Remove(tmp.Name())
|
||||||
|
// fmt.Println("temp", tmp.Name())
|
||||||
|
app.Finish()
|
||||||
|
fmt.Printf("%+v\n", out)
|
||||||
|
// media.Watch(out.Format.Path)
|
||||||
|
show := boolean.Choose("Show stream?")
|
||||||
|
if show {
|
||||||
|
stream := out.WantedAudioStream()
|
||||||
|
fmt.Printf("Stream %d of %s: %+v\n", stream.Index, out.Format.Path, stream)
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue