Skip to content

Commit

Permalink
Better CLI UX (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg authored Jan 2, 2022
1 parent e7d7a42 commit 940992e
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The original implementation was started by [@quasilyte](https://github.com/quasi
$ go get -u github.com/go-perf/go-perftuner

# Check installation (prints help):
$ go-perftuner
$ go-perftuner help

# Run almostInlined sub-command on strings and bytes package:
$ go-perftuner almostInlined strings bytes
Expand Down
3 changes: 1 addition & 2 deletions almostInlined.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"flag"
"fmt"
"log"
"os/exec"
"regexp"
)
Expand Down Expand Up @@ -61,7 +60,7 @@ func (r *almostInlinedRunner) Run(pkg string) error {
}

for _, r := range results {
log.Printf("%s: %s: budget exceeded by %d\n", r.Loc, r.Fn, r.Diff)
fmt.Printf("%s: %s: budget exceeded by %d\n", r.Loc, r.Fn, r.Diff)
}
return nil
}
Expand Down
3 changes: 1 addition & 2 deletions boundChecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"fmt"
"log"
"os/exec"
"regexp"
)
Expand Down Expand Up @@ -42,7 +41,7 @@ func (r *boundCheckRunner) Run(pkg string) error {
}

for _, r := range results {
log.Printf("%s: slice/array has bound checks\n", r.Loc)
fmt.Printf("%s: slice/array has bound checks\n", r.Loc)
}
return nil
}
Expand Down
3 changes: 1 addition & 2 deletions escapeanalysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"fmt"
"log"
"os/exec"
"regexp"
)
Expand Down Expand Up @@ -47,7 +46,7 @@ func (r *escapeAnalysisRunner) Run(pkg string) error {
}

for _, r := range results {
log.Printf("%s: %s\n", r.Loc, r.Variable)
fmt.Printf("%s: %s\n", r.Loc, r.Variable)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/go-perf/go-perftuner

go 1.10

require github.com/cristalhq/acmd v0.3.0
require github.com/cristalhq/acmd v0.5.0
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/cristalhq/acmd v0.3.0 h1:P9/h5Mn5OlRCEu1+b7bFWMBPenC6LORwc76vpf/GK0E=
github.com/cristalhq/acmd v0.3.0/go.mod h1:LG5oa43pE/BbxtfMoImHCQN++0Su7dzipdgBjMCBVDQ=
github.com/cristalhq/acmd v0.5.0 h1:0bzePcUUuzazlaAJoZmDTnL9396RwqrdA16m5+LpBhY=
github.com/cristalhq/acmd v0.5.0/go.mod h1:LG5oa43pE/BbxtfMoImHCQN++0Su7dzipdgBjMCBVDQ=
11 changes: 3 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"flag"
"fmt"
"log"
"os"
"strings"

Expand All @@ -19,11 +18,6 @@ var (
)

func main() {
if len(os.Args) < 2 {
panic("not enough arguments, expected sub-command name")
}

log.SetFlags(0)
flag.StringVar(&flagMod, "mod", "", `-mod compiler flag(readonly|vendor)`)
flag.BoolVar(&asJSON, "json", false, `return result as JSON`)
flag.Parse()
Expand All @@ -32,7 +26,8 @@ func main() {
Version: version,
})
if err := r.Run(); err != nil {
log.Fatal(fmt.Errorf("dbumper: %w", err))
fmt.Printf("go-perf: %v\n", err)
os.Exit(1)
}
}

Expand Down Expand Up @@ -72,7 +67,7 @@ func run(cmd subCommandRunner) error {
cmd.Init()
for _, pkg := range flag.Args()[1:] {
if err := cmd.Run(pkg); err != nil {
log.Printf("%s: %v", pkg, err)
fmt.Printf("%s: %v", pkg, err)
}
}
return nil
Expand Down

0 comments on commit 940992e

Please sign in to comment.