Skip to content

Commit 17f178a

Browse files
committed
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
1 parent 661c496 commit 17f178a

4 files changed

Lines changed: 8 additions & 4 deletions

File tree

cmd/pp/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
func main() {
27-
if err := internal.Main(); err != nil {
27+
if err := internal.Main("/cmd/pp"); err != nil {
2828
fmt.Fprintf(os.Stderr, "Failed: %s\n", err)
2929
os.Exit(1)
3030
}

internal/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func showBanner() bool {
117117
// Main is implemented here so both 'pp' and 'panicparse' executables can be
118118
// compiled. This is to work around the Perl Package manager 'pp' that is
119119
// preinstalled on some OSes.
120-
func Main() error {
120+
func Main(rel string) error {
121121
aggressive := flag.Bool("aggressive", false, "Aggressive deduplication including non pointers")
122122
parse := flag.Bool("parse", true, "Parses source files to deduct types; use -parse=false to work around bugs in source parser")
123123
rebase := flag.Bool("rebase", true, "Guess GOROOT and GOPATH")
@@ -138,6 +138,10 @@ func Main() error {
138138
log.SetOutput(ioutil.Discard)
139139
}
140140

141+
if os.Getenv("PANICPARSE_V1_NO_WARN") != "1" {
142+
fmt.Fprintf(os.Stderr, "More features! Upgrade to panicparse v2 with: go get github.com/maruel/panicparse/v2%s\n", rel)
143+
}
144+
141145
var err error
142146
var filter *regexp.Regexp
143147
if *filterFlag != "" {

internal/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func TestProcessFilter(t *testing.T) {
8383
func TestMainFn(t *testing.T) {
8484
t.Parallel()
8585
// It doesn't do anything since stdin is closed.
86-
if err := Main(); err != nil {
86+
if err := Main(""); err != nil {
8787
t.Fatal(err)
8888
}
8989
}

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
func main() {
27-
if err := internal.Main(); err != nil {
27+
if err := internal.Main(""); err != nil {
2828
fmt.Fprintf(os.Stderr, "Failed: %s\n", err)
2929
os.Exit(1)
3030
}

0 commit comments

Comments
 (0)