cli

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package cli defines the structures to store the CLI flags used by the scanner binary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateFlags

func ValidateFlags(flags *Flags) error

ValidateFlags validates the passed command line flags.

Types

type Array

type Array []string

Array is a type to be passed to flag.Var that supports arrays passed as repeated flags, e.g. ./scalibr -o binproto=out.bp -o spdx23-json=out.spdx.json

func (*Array) Get

func (i *Array) Get() any

Get returns the underlying []string value stored by this flag struct.

func (*Array) Set

func (i *Array) Set(value string) error

Set gets called whenever a new instance of a flag is read during CLI arg parsing. For example, in the case of -o foo -o bar the library will call arr.Set("foo") then arr.Set("bar").

func (*Array) String

func (i *Array) String() string

type Flags

type Flags struct {
	PrintVersion               bool
	Root                       string
	ResultFile                 string
	Output                     Array
	ExtractorsToRun            []string
	DetectorsToRun             []string
	AnnotatorsToRun            []string
	PluginsToRun               []string
	PathsToExtract             []string
	IgnoreSubDirs              bool
	DirsToSkip                 []string
	SkipDirRegex               string
	SkipDirGlob                string
	MaxFileSize                int
	UseGitignore               bool
	RemoteImage                string
	ImageLocal                 string
	ImageTarball               string
	ImagePlatform              string
	GoBinaryVersionFromContent bool
	GovulncheckDBPath          string
	SPDXDocumentName           string
	SPDXDocumentNamespace      string
	SPDXCreators               string
	CDXComponentName           string
	CDXComponentType           string
	CDXComponentVersion        string
	CDXAuthors                 string
	Verbose                    bool
	ExplicitExtractors         bool
	FilterByCapabilities       bool
	StoreAbsolutePath          bool
	WindowsAllDrives           bool
	Offline                    bool
	LocalRegistry              string
}

Flags contains a field for all the cli flags that can be set.

func (*Flags) GetCDXConfig added in v0.1.2

func (f *Flags) GetCDXConfig() converter.CDXConfig

GetCDXConfig creates a CDXConfig struct based on the CLI flags.

func (*Flags) GetSPDXConfig

func (f *Flags) GetSPDXConfig() converter.SPDXConfig

GetSPDXConfig creates an SPDXConfig struct based on the CLI flags.

func (*Flags) GetScanConfig

func (f *Flags) GetScanConfig() (*scalibr.ScanConfig, error)

GetScanConfig constructs a SCALIBR scan config from the provided CLI flags.

func (*Flags) WriteScanResults

func (f *Flags) WriteScanResults(result *scalibr.ScanResult) error

WriteScanResults writes SCALIBR scan results to files specified by the CLI flags.

type StringListFlag added in v0.1.4

type StringListFlag struct {
	// contains filtered or unexported fields
}

StringListFlag is a type to be passed to flag.Var that supports list flags passed as repeated flags, e.g. ./scalibr -o a -o b,c the library will call arr.Set("a") then arr.Set("a,b").

func NewStringListFlag added in v0.1.4

func NewStringListFlag(defaultValue []string) StringListFlag

NewStringListFlag creates a new StringListFlag with the given default value.

func (*StringListFlag) Get added in v0.1.4

func (s *StringListFlag) Get() any

Get returns the underlying []string value stored by this flag struct.

func (*StringListFlag) GetSlice added in v0.1.4

func (s *StringListFlag) GetSlice() []string

GetSlice returns the underlying []string value stored by this flag struct.

func (*StringListFlag) Reset added in v0.1.5

func (s *StringListFlag) Reset()

Reset resets the flag to its default value.

func (*StringListFlag) Set added in v0.1.4

func (s *StringListFlag) Set(x string) error

Set gets called whenever a new instance of a flag is read during CLI arg parsing. For example, in the case of -o foo -o bar the library will call arr.Set("foo") then arr.Set("bar").

func (*StringListFlag) String added in v0.1.4

func (s *StringListFlag) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL