♻️ Move convids cmd code to internal App
This commit is contained in:
parent
64b2242567
commit
ac0baba3a8
4 changed files with 99 additions and 42 deletions
29
internal/cli/convids/walker.go
Normal file
29
internal/cli/convids/walker.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package convids
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"codeberg.org/danjones000/utils/chill"
|
||||
"codeberg.org/danjones000/utils/cli/spin"
|
||||
conutils "codeberg.org/danjones000/utils/convids"
|
||||
)
|
||||
|
||||
func GetWalker(ctx context.Context, dryRun bool, in io.Reader, out, errOut io.Writer) conutils.ShowWalker {
|
||||
if dryRun {
|
||||
return conutils.DryRun(out)
|
||||
}
|
||||
|
||||
gs := conutils.GetShowWithIO(ctx, in, out, errOut)
|
||||
return func(s *conutils.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)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue