Improve lint tool inventory output

This commit is contained in:
Virgil 2026-04-01 07:19:43 +00:00
parent c82c57748c
commit be7f9fe966
2 changed files with 26 additions and 1 deletions

View file

@ -159,7 +159,11 @@ func newToolsCommand(commandName string, summary string) *cli.Command {
if tool.Available {
status = "available"
}
fmt.Fprintf(command.OutOrStdout(), "%-14s [%-11s] %s\n", tool.Name, tool.Category, status)
line := fmt.Sprintf("%-14s [%-11s] %s langs=%s", tool.Name, tool.Category, status, strings.Join(tool.Languages, ","))
if tool.Entitlement != "" {
line += " entitlement=" + tool.Entitlement
}
fmt.Fprintln(command.OutOrStdout(), line)
}
return nil
case "json":

View file

@ -105,6 +105,27 @@ func TestCLI_Init_WritesConfig(t *testing.T) {
assert.Contains(t, string(content), "fail_on: error")
}
func TestCLI_Tools_TextIncludesMetadata(t *testing.T) {
buildCLI(t)
binDir := t.TempDir()
fakeToolPath := filepath.Join(binDir, "gosec")
require.NoError(t, os.WriteFile(fakeToolPath, []byte("#!/bin/sh\nexit 0\n"), 0o755))
t.Setenv("PATH", binDir+string(os.PathListSeparator)+os.Getenv("PATH"))
command := exec.Command(buildCLI(t), "tools", "--lang", "go")
command.Dir = t.TempDir()
command.Env = os.Environ()
output, err := command.CombinedOutput()
require.NoError(t, err, string(output))
text := string(output)
assert.Contains(t, text, "gosec")
assert.Contains(t, text, "langs=go")
assert.Contains(t, text, "entitlement=lint.security")
}
func TestCLI_HookInstallRemove(t *testing.T) {
if _, err := exec.LookPath("git"); err != nil {
t.Skip("git not available")