✨ convids seems to work properly now
This commit is contained in:
parent
0272aa3b22
commit
5e8f954a14
3 changed files with 99 additions and 34 deletions
|
|
@ -1,10 +1,14 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"codeberg.org/danjones000/utils/chill"
|
||||
c "codeberg.org/danjones000/utils/cli/context"
|
||||
e "codeberg.org/danjones000/utils/cli/err"
|
||||
"codeberg.org/danjones000/utils/cli/spin"
|
||||
"codeberg.org/danjones000/utils/convids"
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
|
|
@ -22,19 +26,43 @@ func main() {
|
|||
os.Exit(2)
|
||||
}
|
||||
|
||||
*dryRun = true // @todo temp
|
||||
ctx, done := c.SelfCancelingCotext(context.Background())
|
||||
defer done()
|
||||
|
||||
var walker convids.ShowWalker
|
||||
if *dryRun {
|
||||
*loop = false
|
||||
walker = convids.DryRun(os.Stdout)
|
||||
}
|
||||
} else {
|
||||
gs := convids.GetShow(ctx)
|
||||
|
||||
if *loop {
|
||||
fmt.Println("looping")
|
||||
walker = func(s *convids.Show, path string) error {
|
||||
ct := chill.Chill(ctx)
|
||||
msg := fmt.Sprintf("Waiting for CPU to cool, for %s", path)
|
||||
sp := spin.Spin(ct, msg)
|
||||
err := sp.Wait()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return gs(s, path)
|
||||
}
|
||||
}
|
||||
|
||||
data, err := convids.NewData(dataPath)
|
||||
e.HandleErr(err)
|
||||
|
||||
convids.WalkFiles(data, false, convids.PrintGroupName(os.Stdout), walker)
|
||||
groupPrinter := convids.PrintGroupName(os.Stdout)
|
||||
|
||||
if *loop {
|
||||
fmt.Println("looping")
|
||||
for err == nil {
|
||||
err = convids.WalkFiles(data, false, groupPrinter, walker)
|
||||
fmt.Println(err)
|
||||
}
|
||||
} else {
|
||||
err = convids.WalkFiles(data, false, groupPrinter, walker)
|
||||
}
|
||||
e.HandleErr(err)
|
||||
|
||||
fmt.Println("Done!")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue