cmd

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package cmd provides ...

Index

Constants

View Source
const (
	ExitSuccess       = 0
	ExitGeneralError  = 1
	ExitConfigError   = 2
	ExitInternalError = 3
	ExitInterrupted   = 130
)
View Source
const (
	// VendorDirPrefix is the vendor directory prefix for exclusion.
	VendorDirPrefix = "vendor" + string(filepath.Separator)
	// VendorDirInPath is the vendor directory marker when it appears in a path.
	VendorDirInPath = string(filepath.Separator) + VendorDirPrefix
	// DSStoreFile is the macOS Finder metadata file that should always be excluded.
	DSStoreFile = ".DS_Store"
	// GitDirPrefix is the Git directory prefix for exclusion.
	GitDirPrefix = ".git" + string(filepath.Separator)
	// GitDirInPath is the Git directory marker when it appears in a path.
	GitDirInPath = string(filepath.Separator) + GitDirPrefix
	// NodeModulesDirPrefix is the node_modules directory prefix for exclusion.
	NodeModulesDirPrefix = "node_modules" + string(filepath.Separator)
	// NodeModulesDirInPath is the node_modules directory marker when it appears in a path.
	NodeModulesDirInPath = string(filepath.Separator) + NodeModulesDirPrefix
)

Directory exclusion constants.

Variables

View Source
var (
	Version = "dev"     //nolint:gochecknoglobals // Build-time variables meant to be overridden
	Commit  = "unknown" //nolint:gochecknoglobals
	Date    = "unknown" //nolint:gochecknoglobals
)

Version information - can be overridden during build.

Functions

func AddFlags

func AddFlags(rootCmd *cobra.Command)

AddFlags adds all flags to the root command.

func BuildConfigFromFlags

func BuildConfigFromFlags(cmd *cobra.Command, args []string) (*config.Config, error)

BuildConfigFromFlags extracts flag values and builds a merged configuration. This function handles the common config-building logic shared between run and stats commands.

func ExitCodeForError added in v0.4.0

func ExitCodeForError(err error) int

ExitCodeForError maps an error to the appropriate process exit code. nil error returns ExitSuccess. Context cancellation returns ExitInterrupted. Config/validation errors return ExitConfigError. Everything else returns ExitGeneralError.

func GetBuildDate

func GetBuildDate() string

GetBuildDate returns build date.

func GetCommit

func GetCommit() string

GetCommit returns commit hash.

func GetVersion

func GetVersion() string

GetVersion returns version information including build info.

func NewBaselineCommand added in v0.4.0

func NewBaselineCommand() *cobra.Command

NewBaselineCommand creates the `baseline` subcommand that snapshots the currently-detected clones into a baseline file for later CI comparison.

func NewCheckCommand added in v0.4.0

func NewCheckCommand() *cobra.Command

NewCheckCommand creates the `check` subcommand that reports only new clones relative to a baseline, exiting non-zero if any are found. Designed for CI.

func NewRootCommand

func NewRootCommand() *cobra.Command

NewRootCommand creates the root Cobra command.

func NewStatsCommand

func NewStatsCommand() *cobra.Command

NewStatsCommand creates the stats command.

func NewVersionCommand added in v0.4.0

func NewVersionCommand() *cobra.Command

NewVersionCommand creates the version subcommand.

func PrintVersion

func PrintVersion()

PrintVersion prints version information.

Types

type CrawlOptions

type CrawlOptions struct {
	Ctx             context.Context
	Filter          *gogenfilter.Filter
	FilterStats     *FilterStats
	Includes        generatorIncludes
	IncludeVendor   bool
	IncludeNodeMods bool
	FileCheck       fileCheckFunc
	FChan           chan string
}

CrawlOptions contains the common options for crawling operations.

type FilterStats added in v0.2.0

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

FilterStats holds aggregated filter statistics. Replaces the removed gogenfilter.FilterStats type — stats aggregation is now the caller's responsibility per gogenfilter's API redesign.

func NewFilterStats added in v0.2.0

func NewFilterStats(reasons []gogenfilter.FilterReason) *FilterStats

NewFilterStats creates a new FilterStats with the given filter reasons.

func (*FilterStats) Breakdown added in v0.2.0

func (s *FilterStats) Breakdown() map[string]int

Breakdown returns a copy of the per-reason breakdown.

func (*FilterStats) FilteredBy added in v0.2.0

func (s *FilterStats) FilteredBy(reason string) int

FilteredBy returns the number of files filtered by the given reason.

func (*FilterStats) Reasons added in v0.2.0

func (s *FilterStats) Reasons() []gogenfilter.FilterReason

Reasons returns the filter reasons this tracker was configured with.

func (*FilterStats) Record added in v0.2.0

func (s *FilterStats) Record(result gogenfilter.FilterResult)

Record records a filter result.

func (*FilterStats) TotalFiltered added in v0.2.0

func (s *FilterStats) TotalFiltered() int

TotalFiltered returns the total number of filtered files.

type SuppressionConfig added in v0.4.0

type SuppressionConfig struct {
	SuppressTestLow bool
	TestThreshold   int
	MinLines        int
}

SuppressionConfig groups the filter thresholds used to suppress clone groups. Passing it as a single value avoids 3-parameter function signatures that are prone to argument-swap bugs.

type VersionInfo added in v0.4.0

type VersionInfo struct {
	Version   string `json:"version"`
	Commit    string `json:"commit"`
	Date      string `json:"date"`
	GoVersion string `json:"goVersion"`
	Compiler  string `json:"compiler"`
	Platform  string `json:"platform"`
	Arch      string `json:"arch"`
}

VersionInfo provides structured version information for CI tooling.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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