diff --git a/Makefile b/Makefile index b700ab0..c7c5ad3 100644 --- a/Makefile +++ b/Makefile @@ -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" \ No newline at end of file diff --git a/cmd/catp.pgo b/cmd/catp.pgo index 6b2dfdf..1274f82 100644 Binary files a/cmd/catp.pgo and b/cmd/catp.pgo differ diff --git a/cmd/catp/main.go b/cmd/catp/main.go index a7ef8ff..322e100 100644 --- a/cmd/catp/main.go +++ b/cmd/catp/main.go @@ -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" @@ -99,7 +100,6 @@ func (r *runner) cat(filename string) { } if r.reverse { - } r.pr.Start(func(t *progress.Task) { @@ -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 { @@ -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)) }, } diff --git a/cmd/go.mod b/cmd/go.mod index 192ac1a..e133dda 100644 --- a/cmd/go.mod +++ b/cmd/go.mod @@ -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 diff --git a/cmd/go.sum b/cmd/go.sum index d4b1c79..1239591 100644 --- a/cmd/go.sum +++ b/cmd/go.sum @@ -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=