Skip to content

Commit

Permalink
term
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Scherba <[email protected]>
  • Loading branch information
miklezzzz committed Jan 20, 2025
1 parent ecabcaf commit 9c9c981
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ require (
// Remove 'in body' from errors, fix for Go 1.16 (https://github.com/go-openapi/validate/pull/138).
replace github.com/go-openapi/validate => github.com/flant/go-openapi-validate v0.19.12-flant.0

require github.com/gojuno/minimock/v3 v3.4.3
require (
github.com/buger/goterm v1.0.4
github.com/gojuno/minimock/v3 v3.4.3
)

require (
github.com/DataDog/gostackparse v0.7.0 // indirect
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535/go.mod h1:o
github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/buger/goterm v1.0.4 h1:Z9YvGmOih81P0FbVtEYTFF6YsSgxSUKEhf/f9bTMXbY=
github.com/buger/goterm v1.0.4/go.mod h1:HiFWV3xnkolgrBV3mY8m0X0Pumt4zg4QhbdOzQtB8tE=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down Expand Up @@ -343,6 +345,7 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
Expand Down
9 changes: 7 additions & 2 deletions pkg/debug/debug-cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"time"

"github.com/buger/goterm"
"gopkg.in/alecthomas/kingpin.v2"

"github.com/flant/shell-operator/pkg/app"
Expand All @@ -24,23 +25,27 @@ func DefineDebugCommands(kpApp *kingpin.Application) {
Action(func(_ *kingpin.ParseContext) error {
var refreshInterval time.Duration
if watch {
goterm.Clear()
var err error
refreshInterval, err = time.ParseDuration(watchInterval)
if err != nil {
return fmt.Errorf("couldn't parse watch refresh interval: %w", err)
goterm.Println(fmt.Sprintf("couldn't parse watch refresh interval: %s, default 1s applied\n", err))
refreshInterval = time.Duration(1 * time.Second)

Check failure on line 33 in pkg/debug/debug-cmd.go

View workflow job for this annotation

GitHub Actions / Run linter

unnecessary conversion (unconvert)
}
}
for {
out, err := Queue(DefaultClient()).List(outputFormat, showEmpty)
if err != nil {
return err
}
fmt.Println(string(out))
goterm.Println(string(out))
goterm.Flush()

if !watch {
break
}
time.Sleep(refreshInterval)
goterm.MoveCursor(1, 1)
}
return nil
})
Expand Down

0 comments on commit 9c9c981

Please sign in to comment.