Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vendor: update urfave/cli to v2.11.2 #495

Merged
merged 1 commit into from
Sep 1, 2022

Conversation

boraberke
Copy link
Contributor

@boraberke boraberke commented Aug 24, 2022

Old version of urfave/cli unnecessarily prints help page if an error occurred related to the arguments/flags.

After updating v2.11.2, unnecessary help prints will be removed and only the error messages will appear.

@boraberke boraberke requested a review from a team as a code owner August 24, 2022 10:47
@boraberke boraberke requested review from aykutfarsak and sonmezonur and removed request for a team August 24, 2022 10:47
@igungor
Copy link
Member

igungor commented Aug 31, 2022

After updating v2.11.2, unnecessary help prints will be removed and only the error messages will appear.

I still see the help output:

s5cmd git:update-urfave-cli Δ go build .
s5cmd git:update-urfave-cli Δ ./s5cmd cp -naber
Incorrect Usage: flag provided but not defined: -naber

Name:
  cp - copy objects

Usage:
  cp [options] source destination
...

@boraberke
Copy link
Contributor Author

After updating v2.11.2, unnecessary help prints will be removed and only the error messages will appear.

I still see the help output:

s5cmd git:update-urfave-cli Δ go build .
s5cmd git:update-urfave-cli Δ ./s5cmd cp -naber
Incorrect Usage: flag provided but not defined: -naber

Name:
  cp - copy objects

Usage:
  cp [options] source destination
...

Yes, if a non-existing flag is given, it still prints the help message. However, in the following cases, it does not print the help message anymore:

  1. Incorrect usage of a command
boraberke@192 s5cmd % go build .    
boraberke@192 s5cmd % ./s5cmd cp naber
ERROR "cp naber": expected source and destination arguments
  1. Incorrect values given to a flag
boraberke@192 s5cmd % go build .    
boraberke@192 s5cmd % ./s5cmd --retry-count -5
ERROR retry count cannot be a negative value

@igungor igungor merged commit deb16c9 into peak:master Sep 1, 2022
boraberke added a commit to boraberke/s5cmd that referenced this pull request Sep 9, 2022
after peak#495, `s5cmd --help` started to panic:

```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x158798e]

goroutine 1 [running]:
github.com/peak/s5cmd/parallel.(*Manager).Close(...)
        /Users/boraberkesahin/Documents/s5cmd/parallel/parallel.go:65
github.com/peak/s5cmd/parallel.Close(...)
        /Users/boraberkesahin/Documents/s5cmd/parallel/global.go:16
github.com/peak/s5cmd/command.glob..func5(0x16af2c0?)
        /Users/boraberkesahin/Documents/s5cmd/command/app.go:177 +0x10e
github.com/urfave/cli/v2.(*App).RunContext.func1()
        /Users/boraberkesahin/Documents/s5cmd/vendor/github.com/urfave/cli/v2/app.go:309 +0x35
github.com/urfave/cli/v2.(*App).RunContext(0x1bf3c20, {0x1857a30?, 0xc000030e80}, {0xc000020040, 0x2, 0x2})
        /Users/boraberkesahin/Documents/s5cmd/vendor/github.com/urfave/cli/v2/app.go:321 +0xa5b
github.com/peak/s5cmd/command.Main({0x1857a30, 0xc000030e80}, {0xc000020040, 0x2, 0x2})
        /Users/boraberkesahin/Documents/s5cmd/command/app.go:235 +0xa6
main.main()
        /Users/boraberkesahin/Documents/s5cmd/main.go:23 +0x9b
```

This is caused by (this PR)[urfave/cli@a1c26d5] from urfave/cli. `app.After` is called before `app.Before` is called. Fix this bug by making nil checks.
ilkinulas pushed a commit that referenced this pull request Sep 13, 2022
after #495, `s5cmd --help` started to panic:

```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x158798e]

goroutine 1 [running]:
github.com/peak/s5cmd/parallel.(*Manager).Close(...)
        /Users/boraberke/Documents/s5cmd/parallel/parallel.go:65
github.com/peak/s5cmd/parallel.Close(...)
        /Users/boraberke/Documents/s5cmd/parallel/global.go:16
github.com/peak/s5cmd/command.glob..func5(0x16af2c0?)
        /Users/boraberke/Documents/s5cmd/command/app.go:177 +0x10e
github.com/urfave/cli/v2.(*App).RunContext.func1()
        /Users/boraberke/Documents/s5cmd/vendor/github.com/urfave/cli/v2/app.go:309 +0x35
github.com/urfave/cli/v2.(*App).RunContext(0x1bf3c20, {0x1857a30?, 0xc000030e80}, {0xc000020040, 0x2, 0x2})
        /Users/boraberke/Documents/s5cmd/vendor/github.com/urfave/cli/v2/app.go:321 +0xa5b
github.com/peak/s5cmd/command.Main({0x1857a30, 0xc000030e80}, {0xc000020040, 0x2, 0x2})
        /Users/boraberke/Documents/s5cmd/command/app.go:235 +0xa6
main.main()
        /Users/boraberke/Documents/s5cmd/main.go:23 +0x9b
```

This is caused by [this
commit](urfave/cli@a1c26d5)
from urfave/cli. `app.After` is deferred before `showAppHelp` is called.
Fix this bug by making nil checks in log.go and parallel.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants