From 282b3293c5443c4ed278fc155085e771ac20c8fe Mon Sep 17 00:00:00 2001 From: bagtoad <47394200+BagToad@users.noreply.github.com> Date: Wed, 9 Oct 2024 21:21:13 -0600 Subject: [PATCH] Add SPDX ID to license list output --- pkg/cmd/repo/license/list/list.go | 3 ++- pkg/cmd/repo/license/list/list_test.go | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pkg/cmd/repo/license/list/list.go b/pkg/cmd/repo/license/list/list.go index d02c8c6d1..485a92df0 100644 --- a/pkg/cmd/repo/license/list/list.go +++ b/pkg/cmd/repo/license/list/list.go @@ -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() } diff --git a/pkg/cmd/repo/license/list/list_test.go b/pkg/cmd/repo/license/list/list_test.go index b01d64d9a..b626a25d8 100644 --- a/pkg/cmd/repo/license/list/list_test.go +++ b/pkg/cmd/repo/license/list/list_test.go @@ -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{}, },