Skip to content

Conversation

@u-ways
Copy link
Contributor

@u-ways u-ways commented Dec 30, 2025

Background

This PR adds a new --stdout flag that allows users to specify an output format for stdout while also writing a different format to a file using the --file flag.

Tip

This enables workflows where users want both a human-readable table output in the console and a machine-readable format (like SARIF or JSON) saved to a file.

Usage

# Write SARIF to a file while displaying table format in the terminal
grype <image> -o sarif --file grype-scan-results.sarif --stdout table

# Write JSON to a file while displaying table format in the terminal
grype <image> -o json --file results.json --stdout table

# Write CycloneDX to a file while displaying table format in the terminal
grype <image> -o cyclonedx-json --file sbom.json --stdout table

Why?

Because I ended up having to run Grype twice to get the nice table output:

$GRYPE_CMD sbom:$GRYPE_SBOM_PATH $GRYPE_CLI_OVERRIDE_ARGS -o table > $SUMMARY_FILE
$GRYPE_CMD sbom:$GRYPE_SBOM_PATH $GRYPE_CLI_OVERRIDE_ARGS -o sarif --file grype-scan-results.sarif

Which I prefer to have for concise GH summaries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant