Skip to content

Avoid duplicate output and print all forbidden licenses#60

Merged
Bobgy merged 2 commits intogoogle:masterfrom
lavrd:master
May 20, 2022
Merged

Avoid duplicate output and print all forbidden licenses#60
Bobgy merged 2 commits intogoogle:masterfrom
lavrd:master

Conversation

@lavrd
Copy link
Copy Markdown
Contributor

@lavrd lavrd commented Apr 7, 2021

First update

I added following lines to avoid duplicate output on error:

rootCmd.SilenceErrors = true // to avoid duplicate error output
rootCmd.SilenceUsage = true  // to avoid usage/help output on error

For example, we have two folders (./test1, test2) with GNU AGPLv3 license.
When I execute following command:

go run . check ./test

And ./test folder is not exists, we have following output:

Error: errors for ["./test"]:
./test: -: stat /Users/lavr/dev/github/go-licenses/test: directory not found
Usage:
  licenses check <package> [flags]

Flags:
  -h, --help   help for check

Global Flags:
      --alsologtostderr                  log to standard error as well as files
      --confidence_threshold float       Minimum confidence required in order to positively identify a license. (default 0.9)
      --log_backtrace_at traceLocation   when logging hits line file:N, emit a stack trace (default :0)
      --log_dir string                   If non-empty, write log files in this directory
      --logtostderr                      log to standard error instead of files
      --stderrthreshold severity         logs at or above this threshold go to stderr (default 2)
  -v, --v Level                          log level for V logs
      --vmodule moduleSpec               comma-separated list of pattern=N settings for file-filtered logging

F0407 11:24:23.832579    7607 main.go:45] errors for ["./test"]:
./test: -: stat /Users/lavr/dev/github/go-licenses/test: directory not found
exit status 1

So, in this output we have error, then usage output, and error again. The first error message and usage output looks unnecessary.
But with my update output will be:

F0407 11:27:19.847123    7648 main.go:45] errors for ["./test"]:
./test: -: stat /Users/lavr/dev/github/go-licenses/test: directory not found
exit status 1

And it is look nicer.

Second update

I added a code to print all forbidden license before program exit. I think it will be more convenient to check for all forbidden licenses.

For example, we have two folders (./test1, test2) with GNU AGPLv3 license.

Output without updates:

$ go run . check ./test1 ./test2
Forbidden license type AGPL-3.0 for library github.com/google/go-licenses/test1
exit status 1

Output with updates:

$ go run . check ./test1 ./test2
Forbidden license type AGPL-3.0 for library github.com/google/go-licenses/test1
Forbidden license type AGPL-3.0 for library github.com/google/go-licenses/test2
exit status 1

@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 7, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no Contributor license agreement not signed (https://cla.developers.google.com) label Apr 7, 2021
@lavrd
Copy link
Copy Markdown
Contributor Author

lavrd commented Apr 7, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.

What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@googlebot I signed it!

@google-cla google-cla bot added cla: yes Contributor license agreement signed (https://cla.developers.google.com) and removed cla: no Contributor license agreement not signed (https://cla.developers.google.com) labels Apr 7, 2021
Copy link
Copy Markdown
Collaborator

@Bobgy Bobgy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! These are neat improvements!

@Bobgy Bobgy merged commit e69cf6e into google:master May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Contributor license agreement signed (https://cla.developers.google.com)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants