Add SPDX ID to license list output

This commit is contained in:
bagtoad 2024-10-09 21:21:13 -06:00
parent d6c6c6b40c
commit 282b3293c5
2 changed files with 11 additions and 10 deletions

View file

@ -77,9 +77,10 @@ func listRun(opts *ListOptions) error {
}
func renderLicenseTemplatesTable(licenseTemplates []api.License, opts *ListOptions) error {
t := tableprinter.New(opts.IO, tableprinter.WithHeader("LICENSE KEY", "LICENSE NAME"))
t := tableprinter.New(opts.IO, tableprinter.WithHeader("LICENSE KEY", "SPDX ID", "LICENSE NAME"))
for _, l := range licenseTemplates {
t.AddField(l.Key)
t.AddField(l.SPDXID)
t.AddField(l.Name)
t.EndRow()
}

View file

@ -133,15 +133,15 @@ func TestListRun(t *testing.T) {
))
},
wantStdout: heredoc.Doc(`
LICENSE KEY LICENSE NAME
mit MIT License
lgpl-3.0 GNU Lesser General Public License v3.0
mpl-2.0 Mozilla Public License 2.0
agpl-3.0 GNU Affero General Public License v3.0
unlicense The Unlicense
apache-2.0 Apache License 2.0
gpl-3.0 GNU General Public License v3.0
`),
LICENSE KEY SPDX ID LICENSE NAME
mit MIT MIT License
lgpl-3.0 LGPL-3.0 GNU Lesser General Public License v3.0
mpl-2.0 MPL-2.0 Mozilla Public License 2.0
agpl-3.0 AGPL-3.0 GNU Affero General Public License v3.0
unlicense Unlicense The Unlicense
apache-2.0 Apache-2.0 Apache License 2.0
gpl-3.0 GPL-3.0 GNU General Public License v3.0
`),
wantStderr: "",
opts: &ListOptions{},
},