Skip to content

Commit

Permalink
internal: Nudge to ugprade to v2
Browse files Browse the repository at this point in the history
If you are reading this, you have three choices:

- Upgrade to v2. Seriously, do this. It's so much better!
- Disable the nudge with the environment variable PANICPARSE_V1_NO_WARN=1
- Stick to v1.5.0.
I
  • Loading branch information
maruel committed Aug 24, 2020
1 parent 661c496 commit 17f178a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/pp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

func main() {
if err := internal.Main(); err != nil {
if err := internal.Main("/cmd/pp"); err != nil {
fmt.Fprintf(os.Stderr, "Failed: %s\n", err)
os.Exit(1)
}
Expand Down
6 changes: 5 additions & 1 deletion internal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func showBanner() bool {
// Main is implemented here so both 'pp' and 'panicparse' executables can be
// compiled. This is to work around the Perl Package manager 'pp' that is
// preinstalled on some OSes.
func Main() error {
func Main(rel string) error {
aggressive := flag.Bool("aggressive", false, "Aggressive deduplication including non pointers")
parse := flag.Bool("parse", true, "Parses source files to deduct types; use -parse=false to work around bugs in source parser")
rebase := flag.Bool("rebase", true, "Guess GOROOT and GOPATH")
Expand All @@ -138,6 +138,10 @@ func Main() error {
log.SetOutput(ioutil.Discard)
}

if os.Getenv("PANICPARSE_V1_NO_WARN") != "1" {
fmt.Fprintf(os.Stderr, "More features! Upgrade to panicparse v2 with: go get github.com/maruel/panicparse/v2%s\n", rel)
}

var err error
var filter *regexp.Regexp
if *filterFlag != "" {
Expand Down
2 changes: 1 addition & 1 deletion internal/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestProcessFilter(t *testing.T) {
func TestMainFn(t *testing.T) {
t.Parallel()
// It doesn't do anything since stdin is closed.
if err := Main(); err != nil {
if err := Main(""); err != nil {
t.Fatal(err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

func main() {
if err := internal.Main(); err != nil {
if err := internal.Main(""); err != nil {
fmt.Fprintf(os.Stderr, "Failed: %s\n", err)
os.Exit(1)
}
Expand Down

0 comments on commit 17f178a

Please sign in to comment.