Compare commits

..

No commits in common. "f41ac8575ffe319a67c2c97683b974c5df0ffa6a" and "2d70d8994ef9caec7f5364621a5785a910b8977d" have entirely different histories.

7 changed files with 11 additions and 94 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
build/
.task/

View file

@ -2,53 +2,13 @@
version: '3'
vars:
GOBIN_ENV:
sh: go env GOBIN
GOPATH_ENV:
sh: go env GOPATH
BIN: '{{if .GOBIN_ENV}}{{.GOBIN_ENV}}{{else}}{{.GOPATH_ENV}}/bin{{end}}'
tasks:
default:
desc: fmt, vet, and build
deps:
- fmt
- analyze
- build-all
fmt:
desc: Format go files
sources:
- "**/*.go"
cmds:
- go fmt ./...
vet:
desc: Vet go code
sources:
- '**/*.go'
cmds:
- go vet ./...
critic:
desc: Critique go code
sources:
- '**/*.go'
cmds:
- gocritic check ./...
staticcheck:
desc: Static check go code
sources:
- '**/*.go'
cmds:
- staticcheck ./...
analyze:
desc: Do static analysis
deps:
- vet
- critic
- staticcheck
cmd-build:
internal: true
cmds:
@ -89,18 +49,3 @@ tasks:
- task: cmd-build
vars:
CMD: "*"
install-cool-down:
desc: Installs the cool-down command
source:
- cmd/cool-down/**/*.go
- chill/*.go
- cli/context/*.go
- cli/err/*.go
- cli/spin/*.go
- go.mod
- go.sum
generates:
- '{{.BIN}}/cool-down'
cmds:
- go install ./cmd/cool-down

2
build/.gitignore vendored
View file

@ -1,2 +0,0 @@
*
!.gitignore

View file

@ -1,21 +0,0 @@
package context
import (
"context"
"os"
"os/signal"
"syscall"
)
func SelfCancelingCotext(ctx context.Context) (context.Context, context.CancelFunc) {
c, done := context.WithCancel(ctx)
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
go func() {
for range ch {
done()
}
}()
return c, done
}

View file

@ -82,24 +82,18 @@ func (s *spin) SetMessage(msg string) {
}
func (s *spin) Err() error {
switch {
case errors.Is(s.err, context.Canceled):
if errors.Is(s.err, context.Canceled) {
return nil
case errors.Is(s.err, context.DeadlineExceeded):
} else if errors.Is(s.err, context.DeadlineExceeded) {
return nil
case errors.Is(s.err, tea.ErrProgramKilled):
} else if errors.Is(s.err, tea.ErrProgramKilled) {
return nil
}
return s.err
}
func Spin(ctx context.Context, message string) Spinner {
p := tea.NewProgram(
newModel(message),
tea.WithContext(ctx),
tea.WithoutSignalHandler(),
tea.WithInput(nil),
)
p := tea.NewProgram(newModel(message), tea.WithContext(ctx))
s := &spin{p: p, finished: make(chan struct{}, 1)}
go func() {
_, err := s.p.Run()

View file

@ -4,15 +4,12 @@ import (
"context"
"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"
)
func main() {
ctx, done := c.SelfCancelingCotext(context.Background())
defer done()
ctx = chill.Chill(ctx)
ctx := chill.Chill(context.Background())
s := spin.Spin(ctx, "Waiting for CPU to cool...")
err := s.Wait()
e.HandleErr(err)

View file

@ -38,7 +38,10 @@ func (s *Show) matchRegexp(path string) (f bool, err error) {
if s.re == nil {
p := s.Pattern
if s.Anime {
p = animePattern + strings.TrimPrefix(p, "^")
if strings.HasPrefix(p, "^") {
p = strings.TrimPrefix(p, "^")
}
p = animePattern + p
} else if !strings.HasPrefix(p, "^") {
p = "^" + p
}
@ -68,7 +71,7 @@ func (d *Data) AllShows(silent bool) iter.Seq[*Show] {
continue
}
if !silent {
fmt.Printf("Checking %s shows\n\n", show)
fmt.Println("Checking", show, "shows\n")
}
for s := range sh.All() {
if s == nil {