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

Switching to google/licensecheck as library #46

Merged
merged 2 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ wwhrd-graph.png

dist/

.idea/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ What would Henry Rollins do?
Application Options:
-v, --version Show CLI version
-q, --quiet quiet mode, do not log accepted packages
-d, --debug verbose mode, log everything

Help Options:
-h, --help Show this help message
Expand Down
19 changes: 14 additions & 5 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ type cliOpts struct {
VersionFlag func() error `long:"version" short:"v" description:"Show CLI version"`

Quiet func() error `short:"q" long:"quiet" description:"quiet mode, do not log accepted packages"`
Debug func() error `short:"d" long:"debug" description:"verbose mode, log everything"`
}

type List struct {
NoColor bool `long:"no-color" description:"disable colored output"`
NoColor bool `long:"no-color" description:"disable colored output"`
CoverageThreshold float64 `short:"c" long:"coverage" description:"coverage threshold is the minimum percentage of the file that must contain license text" default:"75"`
}

type Check struct {
File string `short:"f" long:"file" description:"input file" default:".wwhrd.yml"`
NoColor bool `long:"no-color" description:"disable colored output"`
File string `short:"f" long:"file" description:"input file" default:".wwhrd.yml"`
NoColor bool `long:"no-color" description:"disable colored output"`
CoverageThreshold float64 `short:"c" long:"coverage" description:"coverage threshold is the minimum percentage of the file that must contain license text" default:"75"`
}

type Graph struct {
Expand All @@ -45,6 +48,11 @@ func setQuiet() error {
return nil
}

func setDebug() error {
log.SetLevel(log.DebugLevel)
return nil
}

func newCli() *flags.Parser {
opts := cliOpts{
VersionFlag: func() error {
Expand All @@ -54,6 +62,7 @@ func newCli() *flags.Parser {
}
},
Quiet: setQuiet,
Debug: setDebug,
}
parser := flags.NewParser(&opts, flags.HelpFlag|flags.PassDoubleDash)
parser.LongDescription = "What would Henry Rollins do?"
Expand Down Expand Up @@ -120,7 +129,7 @@ func (l *List) Execute(args []string) error {
if err != nil {
return err
}
lics := GetLicenses(root, pkgs)
lics := GetLicenses(root, pkgs, l.CoverageThreshold)

for k, v := range lics {
log.WithFields(log.Fields{
Expand Down Expand Up @@ -155,7 +164,7 @@ func (c *Check) Execute(args []string) error {
if err != nil {
return err
}
lics := GetLicenses(root, pkgs)
lics := GetLicenses(root, pkgs, c.CoverageThreshold)

// Make a map out of the blacklist
blacklist := make(map[string]bool)
Expand Down
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"os"

yaml "gopkg.in/yaml.v2"
"gopkg.in/yaml.v2"
)

type Config struct {
Expand Down
19 changes: 4 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,14 @@ module github.com/frapposelli/wwhrd
go 1.15

require (
github.com/Microsoft/go-winio v0.4.15 // indirect
github.com/dgryski/go-minhash v0.0.0-20190315135803-ad340ca03076 // indirect
github.com/emicklei/dot v0.15.0
github.com/go-enry/go-license-detector/v4 v4.0.0
github.com/jdkato/prose v1.2.0 // indirect
github.com/google/licensecheck v0.3.1
github.com/jessevdk/go-flags v1.4.0
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shogo82148/go-shuffle v0.0.0-20201027131736-3c5958005202 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/sirupsen/logrus v1.7.0
github.com/stretchr/testify v1.6.1
github.com/xanzy/ssh-agent v0.3.0 // indirect
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9 // indirect
golang.org/x/exp v0.0.0-20201008143054-e3b2a7f2fdc7 // indirect
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect
golang.org/x/text v0.3.4 // indirect
gonum.org/v1/gonum v0.8.1 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v2 v2.3.0
)

replace github.com/ekzhu/minhash-lsh => github.com/ekzhu/minhash-lsh v0.0.0-20171225071031-5c06ee8586a1
156 changes: 2 additions & 154 deletions go.sum

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion vendor/github.com/Microsoft/go-winio/.gitignore

This file was deleted.

22 changes: 0 additions & 22 deletions vendor/github.com/Microsoft/go-winio/LICENSE

This file was deleted.

22 changes: 0 additions & 22 deletions vendor/github.com/Microsoft/go-winio/README.md

This file was deleted.

Loading