Skip to content

Commit 8840cb9

Browse files
export and scan command support default target
1 parent fa6c30f commit 8840cb9

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

cmd/sbom-export.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,20 @@ import (
1313

1414
// sbomExportCmd represents the sbom export command
1515
var sbomExportCmd = &cobra.Command{
16-
Use: "export <package>",
16+
Use: "export [package]",
1717
Short: "Exports the SBOM of a (previously built) package",
1818
Long: `Exports the SBOM of a (previously built) package.
1919
2020
When used with --with-dependencies, it exports SBOMs for the package and all its dependencies
21-
to the specified output directory.`,
22-
Args: cobra.MinimumNArgs(1),
21+
to the specified output directory.
22+
23+
If no package is specified, the workspace's default target is used.`,
24+
Args: cobra.MaximumNArgs(1),
2325
Run: func(cmd *cobra.Command, args []string) {
2426
// Get the package
2527
_, pkg, _, _ := getTarget(args, false)
2628
if pkg == nil {
27-
log.Fatal("sbom export requires a package")
29+
log.Fatal("sbom export requires a package or a default target in the workspace")
2830
}
2931

3032
// Check if SBOM is enabled in workspace settings

cmd/sbom-scan.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,23 @@ import (
1010

1111
// sbomScanCmd represents the sbom scan command
1212
var sbomScanCmd = &cobra.Command{
13-
Use: "scan <package>",
13+
Use: "scan [package]",
1414
Short: "Scans a package's SBOM for vulnerabilities",
1515
Long: `Scans a package's SBOM for vulnerabilities and exports the results to a specified directory.
1616
1717
This command uses existing SBOM files from previously built packages. It checks if SBOM is enabled
1818
in the workspace settings. If not, it aborts. The scan results are exported to the directory
1919
specified by the --output-dir flag.
2020
21-
When used with --with-dependencies, it scans the package and all its dependencies for vulnerabilities.`,
22-
Args: cobra.MinimumNArgs(1),
21+
When used with --with-dependencies, it scans the package and all its dependencies for vulnerabilities.
22+
23+
If no package is specified, the workspace's default target is used.`,
24+
Args: cobra.MaximumNArgs(1),
2325
Run: func(cmd *cobra.Command, args []string) {
2426
// Get the package
2527
_, pkg, _, _ := getTarget(args, false)
2628
if pkg == nil {
27-
log.Fatal("sbom scan requires a package")
29+
log.Fatal("sbom scan requires a package or a default target in the workspace")
2830
}
2931

3032
// Check if SBOM is enabled in workspace settings

cmd/sbom.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import (
88
var sbomCmd = &cobra.Command{
99
Use: "sbom <command>",
1010
Short: "Helpful commands for working with Software Bill of Materials (SBOM)",
11+
Long: `Helpful commands for working with Software Bill of Materials (SBOM).
12+
13+
The subcommands (export, scan) can be used with or without specifying a package.
14+
If no package is specified, the workspace's default target is used.`,
1115
Args: cobra.MinimumNArgs(1),
1216
}
1317

0 commit comments

Comments
 (0)