Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version and verbosity flags #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ BUILD_FLAGS=-trimpath -pgo=./cmd/catp.pgo

# Add your custom targets here.

build-linux-docker:
@docker run -v $$PWD:/app --rm golang bash -c "git config --global --add safe.directory /app && cd /app && make build"
Binary file modified cmd/catp.pgo
Binary file not shown.
14 changes: 13 additions & 1 deletion cmd/catp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"strings"
"time"

"github.com/bool64/dev/version"
"github.com/bool64/progress"
"github.com/klauspost/compress/zstd"
gzip "github.com/klauspost/pgzip"
Expand Down Expand Up @@ -99,7 +100,6 @@ func (r *runner) cat(filename string) {
}

if r.reverse {

}

r.pr.Start(func(t *progress.Task) {
Expand Down Expand Up @@ -127,9 +127,17 @@ func (r *runner) cat(filename string) {
func main() {
grep := flag.String("grep", "", "grep pattern, may contain multiple patterns separated by \\|")
cpuProfile := flag.String("dbg-cpu-prof", "", "write first 10 seconds of CPU profile to file")
ver := flag.Bool("version", false, "print version and exit")
verbosity := flag.Int("verbosity", 1, "progress status verbosity level (0, 1, 2)")

flag.Parse()

if *ver {
fmt.Println(version.Info().Version)

return
}

if *cpuProfile != "" {
f, err := os.Create(*cpuProfile) //nolint:gosec
if err != nil {
Expand Down Expand Up @@ -159,6 +167,10 @@ func main() {
r.pr = &progress.Progress{
Interval: 5 * time.Second,
Print: func(status progress.ProgressStatus) {
if *verbosity == 0 {
return
}

println(r.st(status))
},
}
Expand Down
7 changes: 5 additions & 2 deletions cmd/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ module github.com/bool64/progress/cmd
go 1.20

require (
github.com/bool64/progress v0.1.0
github.com/klauspost/compress v1.16.5
github.com/DataDog/zstd v1.5.5
github.com/bool64/dev v0.2.27
github.com/bool64/progress v0.1.3
github.com/klauspost/pgzip v1.2.5
)

require github.com/klauspost/compress v1.16.5 // indirect
7 changes: 5 additions & 2 deletions cmd/go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ=
github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/bool64/dev v0.2.27 h1:mFT+B74mFVgUeUmm/EbfM6ELPA55lEXBjQ/AOHCwCOc=
github.com/bool64/progress v0.1.0 h1:khsGInrTrQMyskfcRTE9gP982koSqKobYFJ977JLxhA=
github.com/bool64/progress v0.1.0/go.mod h1:XwIA2+r2sEKxIRa6TFR0FqD3GHt0wz4dk4IL5CwbuKo=
github.com/bool64/dev v0.2.27/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg=
github.com/bool64/progress v0.1.3 h1:tW/kDAa0AuOkLBfv9qZyDuqqLgcluyRLDdrTGfqGI9Q=
github.com/bool64/progress v0.1.3/go.mod h1:XwIA2+r2sEKxIRa6TFR0FqD3GHt0wz4dk4IL5CwbuKo=
github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI=
github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE=
Expand Down