Skip to content

Commit

Permalink
Check tty
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW committed Jan 11, 2025
1 parent ca020a9 commit 697ab13
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions cmd/loadt.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/k1LoW/donegroup"
"github.com/k1LoW/duration"
"github.com/k1LoW/runn"
"github.com/mattn/go-isatty"
"github.com/ryo-yamaoka/otchkiss"
"github.com/ryo-yamaoka/otchkiss/setting"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -90,15 +91,25 @@ var loadtCmd = &cobra.Command{
if err != nil {
return err
}
p := tea.NewProgram(newSpinnerModel())
go func() {
_, _ = p.Run()
}()
if err := ot.Start(ctx); err != nil {
return err

if isatty.IsTerminal(os.Stdout.Fd()) {
// With tty
p := tea.NewProgram(newSpinnerModel(), tea.WithContext(ctx))
go func() {
if _, errr := p.Run(); errr != nil {
err = errr
}
}()
if err := ot.Start(ctx); err != nil {
return err
}
p.Quit()
p.Wait()
} else {
if err := ot.Start(ctx); err != nil {
return err
}
}
p.Quit()
p.Wait()

lr, err := runn.NewLoadtResult(len(selected), w, d, flgs.LoadTConcurrent, flgs.LoadTMaxRPS, ot.Result)
if err != nil {
Expand Down

0 comments on commit 697ab13

Please sign in to comment.