Loading tools/compliance/cmd/htmlnotice/htmlnotice.go +8 −2 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ var ( outputFile = flag.String("o", "-", "Where to write the NOTICE text file. (default stdout)") depsFile = flag.String("d", "", "Where to write the deps file") includeTOC = flag.Bool("toc", true, "Whether to include a table of contents.") product = flag.String("product", "", "The name of the product for which the notice is generated.") stripPrefix = newMultiString("strip_prefix", "Prefix to remove from paths. i.e. path to root (multiple allowed)") title = flag.String("title", "", "The title of the notice file.") Loading @@ -47,6 +48,7 @@ type context struct { stderr io.Writer rootFS fs.FS includeTOC bool product string stripPrefix []string title string deps *[]string Loading @@ -57,7 +59,7 @@ func (ctx context) strip(installPath string) string { if strings.HasPrefix(installPath, prefix) { p := strings.TrimPrefix(installPath, prefix) if 0 == len(p) { p = ctx.title p = ctx.product } if 0 == len(p) { continue Loading Loading @@ -139,7 +141,7 @@ func main() { var deps []string ctx := &context{ofile, os.Stderr, os.DirFS("."), *includeTOC, *stripPrefix, *title, &deps} ctx := &context{ofile, os.Stderr, os.DirFS("."), *includeTOC, *product, *stripPrefix, *title, &deps} err := htmlNotice(ctx, flag.Args()...) if err != nil { Loading Loading @@ -204,12 +206,16 @@ func htmlNotice(ctx *context, files ...string) error { fmt.Fprintln(ctx.stdout, "</style>") if 0 < len(ctx.title) { fmt.Fprintf(ctx.stdout, "<title>%s</title>\n", html.EscapeString(ctx.title)) } else if 0 < len(ctx.product) { fmt.Fprintf(ctx.stdout, "<title>%s</title>\n", html.EscapeString(ctx.product)) } fmt.Fprintln(ctx.stdout, "</head>") fmt.Fprintln(ctx.stdout, "<body>") if 0 < len(ctx.title) { fmt.Fprintf(ctx.stdout, " <h1>%s</h1>\n", html.EscapeString(ctx.title)) } else if 0 < len(ctx.product) { fmt.Fprintf(ctx.stdout, " <h1>%s</h1>\n", html.EscapeString(ctx.product)) } ids := make(map[string]string) if ctx.includeTOC { Loading tools/compliance/cmd/htmlnotice/htmlnotice_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -651,7 +651,7 @@ func Test(t *testing.T) { var deps []string ctx := context{stdout, stderr, os.DirFS("."), tt.includeTOC, []string{tt.stripPrefix}, tt.title, &deps} ctx := context{stdout, stderr, os.DirFS("."), tt.includeTOC, "", []string{tt.stripPrefix}, tt.title, &deps} err := htmlNotice(&ctx, rootFiles...) if err != nil { Loading tools/compliance/cmd/textnotice/textnotice.go +7 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import ( var ( outputFile = flag.String("o", "-", "Where to write the NOTICE text file. (default stdout)") depsFile = flag.String("d", "", "Where to write the deps file") product = flag.String("product", "", "The name of the product for which the notice is generated.") stripPrefix = newMultiString("strip_prefix", "Prefix to remove from paths. i.e. path to root (multiple allowed)") title = flag.String("title", "", "The title of the notice file.") Loading @@ -44,6 +45,7 @@ type context struct { stdout io.Writer stderr io.Writer rootFS fs.FS product string stripPrefix []string title string deps *[]string Loading @@ -54,7 +56,7 @@ func (ctx context) strip(installPath string) string { if strings.HasPrefix(installPath, prefix) { p := strings.TrimPrefix(installPath, prefix) if 0 == len(p) { p = ctx.title p = ctx.product } if 0 == len(p) { continue Loading Loading @@ -135,7 +137,7 @@ func main() { var deps []string ctx := &context{ofile, os.Stderr, os.DirFS("."), *stripPrefix, *title, &deps} ctx := &context{ofile, os.Stderr, os.DirFS("."), *product, *stripPrefix, *title, &deps} err := textNotice(ctx, flag.Args()...) if err != nil { Loading Loading @@ -190,6 +192,9 @@ func textNotice(ctx *context, files ...string) error { return fmt.Errorf("Unable to read license text file(s) for %q: %v\n", files, err) } if 0 < len(ctx.title) { fmt.Fprintf(ctx.stdout, "%s\n\n", ctx.title) } for h := range ni.Hashes() { fmt.Fprintln(ctx.stdout, "==============================================================================") for _, libName := range ni.HashLibs(h) { Loading tools/compliance/cmd/textnotice/textnotice_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -564,7 +564,7 @@ func Test(t *testing.T) { var deps []string ctx := context{stdout, stderr, os.DirFS("."), []string{tt.stripPrefix}, "", &deps} ctx := context{stdout, stderr, os.DirFS("."), "", []string{tt.stripPrefix}, "", &deps} err := textNotice(&ctx, rootFiles...) if err != nil { Loading tools/compliance/cmd/xmlnotice/xmlnotice.go +4 −2 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import ( var ( outputFile = flag.String("o", "-", "Where to write the NOTICE xml or xml.gz file. (default stdout)") depsFile = flag.String("d", "", "Where to write the deps file") product = flag.String("product", "", "The name of the product for which the notice is generated.") stripPrefix = newMultiString("strip_prefix", "Prefix to remove from paths. i.e. path to root (multiple allowed)") title = flag.String("title", "", "The title of the notice file.") Loading @@ -45,6 +46,7 @@ type context struct { stdout io.Writer stderr io.Writer rootFS fs.FS product string stripPrefix []string title string deps *[]string Loading @@ -55,7 +57,7 @@ func (ctx context) strip(installPath string) string { if strings.HasPrefix(installPath, prefix) { p := strings.TrimPrefix(installPath, prefix) if 0 == len(p) { p = ctx.title p = ctx.product } if 0 == len(p) { continue Loading Loading @@ -137,7 +139,7 @@ func main() { var deps []string ctx := &context{ofile, os.Stderr, os.DirFS("."), *stripPrefix, *title, &deps} ctx := &context{ofile, os.Stderr, os.DirFS("."), *product, *stripPrefix, *title, &deps} err := xmlNotice(ctx, flag.Args()...) if err != nil { Loading Loading
tools/compliance/cmd/htmlnotice/htmlnotice.go +8 −2 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ var ( outputFile = flag.String("o", "-", "Where to write the NOTICE text file. (default stdout)") depsFile = flag.String("d", "", "Where to write the deps file") includeTOC = flag.Bool("toc", true, "Whether to include a table of contents.") product = flag.String("product", "", "The name of the product for which the notice is generated.") stripPrefix = newMultiString("strip_prefix", "Prefix to remove from paths. i.e. path to root (multiple allowed)") title = flag.String("title", "", "The title of the notice file.") Loading @@ -47,6 +48,7 @@ type context struct { stderr io.Writer rootFS fs.FS includeTOC bool product string stripPrefix []string title string deps *[]string Loading @@ -57,7 +59,7 @@ func (ctx context) strip(installPath string) string { if strings.HasPrefix(installPath, prefix) { p := strings.TrimPrefix(installPath, prefix) if 0 == len(p) { p = ctx.title p = ctx.product } if 0 == len(p) { continue Loading Loading @@ -139,7 +141,7 @@ func main() { var deps []string ctx := &context{ofile, os.Stderr, os.DirFS("."), *includeTOC, *stripPrefix, *title, &deps} ctx := &context{ofile, os.Stderr, os.DirFS("."), *includeTOC, *product, *stripPrefix, *title, &deps} err := htmlNotice(ctx, flag.Args()...) if err != nil { Loading Loading @@ -204,12 +206,16 @@ func htmlNotice(ctx *context, files ...string) error { fmt.Fprintln(ctx.stdout, "</style>") if 0 < len(ctx.title) { fmt.Fprintf(ctx.stdout, "<title>%s</title>\n", html.EscapeString(ctx.title)) } else if 0 < len(ctx.product) { fmt.Fprintf(ctx.stdout, "<title>%s</title>\n", html.EscapeString(ctx.product)) } fmt.Fprintln(ctx.stdout, "</head>") fmt.Fprintln(ctx.stdout, "<body>") if 0 < len(ctx.title) { fmt.Fprintf(ctx.stdout, " <h1>%s</h1>\n", html.EscapeString(ctx.title)) } else if 0 < len(ctx.product) { fmt.Fprintf(ctx.stdout, " <h1>%s</h1>\n", html.EscapeString(ctx.product)) } ids := make(map[string]string) if ctx.includeTOC { Loading
tools/compliance/cmd/htmlnotice/htmlnotice_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -651,7 +651,7 @@ func Test(t *testing.T) { var deps []string ctx := context{stdout, stderr, os.DirFS("."), tt.includeTOC, []string{tt.stripPrefix}, tt.title, &deps} ctx := context{stdout, stderr, os.DirFS("."), tt.includeTOC, "", []string{tt.stripPrefix}, tt.title, &deps} err := htmlNotice(&ctx, rootFiles...) if err != nil { Loading
tools/compliance/cmd/textnotice/textnotice.go +7 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import ( var ( outputFile = flag.String("o", "-", "Where to write the NOTICE text file. (default stdout)") depsFile = flag.String("d", "", "Where to write the deps file") product = flag.String("product", "", "The name of the product for which the notice is generated.") stripPrefix = newMultiString("strip_prefix", "Prefix to remove from paths. i.e. path to root (multiple allowed)") title = flag.String("title", "", "The title of the notice file.") Loading @@ -44,6 +45,7 @@ type context struct { stdout io.Writer stderr io.Writer rootFS fs.FS product string stripPrefix []string title string deps *[]string Loading @@ -54,7 +56,7 @@ func (ctx context) strip(installPath string) string { if strings.HasPrefix(installPath, prefix) { p := strings.TrimPrefix(installPath, prefix) if 0 == len(p) { p = ctx.title p = ctx.product } if 0 == len(p) { continue Loading Loading @@ -135,7 +137,7 @@ func main() { var deps []string ctx := &context{ofile, os.Stderr, os.DirFS("."), *stripPrefix, *title, &deps} ctx := &context{ofile, os.Stderr, os.DirFS("."), *product, *stripPrefix, *title, &deps} err := textNotice(ctx, flag.Args()...) if err != nil { Loading Loading @@ -190,6 +192,9 @@ func textNotice(ctx *context, files ...string) error { return fmt.Errorf("Unable to read license text file(s) for %q: %v\n", files, err) } if 0 < len(ctx.title) { fmt.Fprintf(ctx.stdout, "%s\n\n", ctx.title) } for h := range ni.Hashes() { fmt.Fprintln(ctx.stdout, "==============================================================================") for _, libName := range ni.HashLibs(h) { Loading
tools/compliance/cmd/textnotice/textnotice_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -564,7 +564,7 @@ func Test(t *testing.T) { var deps []string ctx := context{stdout, stderr, os.DirFS("."), []string{tt.stripPrefix}, "", &deps} ctx := context{stdout, stderr, os.DirFS("."), "", []string{tt.stripPrefix}, "", &deps} err := textNotice(&ctx, rootFiles...) if err != nil { Loading
tools/compliance/cmd/xmlnotice/xmlnotice.go +4 −2 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import ( var ( outputFile = flag.String("o", "-", "Where to write the NOTICE xml or xml.gz file. (default stdout)") depsFile = flag.String("d", "", "Where to write the deps file") product = flag.String("product", "", "The name of the product for which the notice is generated.") stripPrefix = newMultiString("strip_prefix", "Prefix to remove from paths. i.e. path to root (multiple allowed)") title = flag.String("title", "", "The title of the notice file.") Loading @@ -45,6 +46,7 @@ type context struct { stdout io.Writer stderr io.Writer rootFS fs.FS product string stripPrefix []string title string deps *[]string Loading @@ -55,7 +57,7 @@ func (ctx context) strip(installPath string) string { if strings.HasPrefix(installPath, prefix) { p := strings.TrimPrefix(installPath, prefix) if 0 == len(p) { p = ctx.title p = ctx.product } if 0 == len(p) { continue Loading Loading @@ -137,7 +139,7 @@ func main() { var deps []string ctx := &context{ofile, os.Stderr, os.DirFS("."), *stripPrefix, *title, &deps} ctx := &context{ofile, os.Stderr, os.DirFS("."), *product, *stripPrefix, *title, &deps} err := xmlNotice(ctx, flag.Args()...) if err != nil { Loading