From 17f178ae50f16b4063a220968daa1ca721b34fe6 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Ruel Date: Sun, 23 Aug 2020 19:57:42 -0400 Subject: [PATCH] internal: Nudge to ugprade to v2 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 --- cmd/pp/main.go | 2 +- internal/main.go | 6 +++++- internal/main_test.go | 2 +- main.go | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/pp/main.go b/cmd/pp/main.go index 2f82a50..a621af2 100644 --- a/cmd/pp/main.go +++ b/cmd/pp/main.go @@ -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) } diff --git a/internal/main.go b/internal/main.go index 5779033..49c061f 100644 --- a/internal/main.go +++ b/internal/main.go @@ -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") @@ -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 != "" { diff --git a/internal/main_test.go b/internal/main_test.go index ce8420f..d9c8d61 100644 --- a/internal/main_test.go +++ b/internal/main_test.go @@ -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) } } diff --git a/main.go b/main.go index 2f82a50..900e15a 100644 --- a/main.go +++ b/main.go @@ -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) }