Documentation
¶
Overview ¶
Package cmd provides CLI commands for the Germinator configuration adapter.
Commands:
adapt - Transform a document to another platform format validate - Validate a document against platform rules canonicalize - Convert a platform document to canonical format version - Display version, commit, and build date library - Manage the canonical resource library init - Install resources from library to project completion - Generate shell completion scripts
All commands use dependency injection through CommandConfig and ServiceContainer.
Index ¶
- func IsCobraArgumentError(err error) bool
- func NewAdaptCommand(cfg *CommandConfig) *cobra.Command
- func NewCanonicalizeCommand(cfg *CommandConfig) *cobra.Command
- func NewCompletionCommand(_ *CommandConfig) *cobra.Command
- func NewConfigCommand(cfg *CommandConfig) *cobra.Command
- func NewConfigInitCommand(cfg *CommandConfig) *cobra.Command
- func NewConfigValidateCommand(cfg *CommandConfig) *cobra.Command
- func NewCreatePresetCommand(cfg *CommandConfig, libraryPath *string) *cobra.Command
- func NewInitCommand(cfg *CommandConfig) *cobra.Command
- func NewLibraryAddCommand(cfg *CommandConfig, libraryPath *string) *cobra.Command
- func NewLibraryCommand(cfg *CommandConfig) *cobra.Command
- func NewLibraryCreateCommand(cfg *CommandConfig, libraryPath *string) *cobra.Command
- func NewLibraryInitCommand(cfg *CommandConfig) *cobra.Command
- func NewLibraryPresetsCommand(cfg *CommandConfig, libraryPath *string) *cobra.Command
- func NewLibraryResourcesCommand(cfg *CommandConfig, libraryPath *string) *cobra.Command
- func NewLibraryShowCommand(cfg *CommandConfig, libraryPath *string) *cobra.Command
- func NewRootCommand(cfg *CommandConfig) *cobra.Command
- func NewValidateCommand(cfg *CommandConfig) *cobra.Command
- func NewVersionCommand(_ *CommandConfig) *cobra.Command
- func SetGlobalCommandConfig(cfg *CommandConfig)
- func VerbosePrint(cfg *CommandConfig, format string, args ...any)
- func VeryVerbosePrint(cfg *CommandConfig, format string, args ...any)
- type CommandConfig
- type ErrorCategory
- type ErrorFormatter
- type ExitCode
- type ServiceContainer
- type ValidationResultError
- type Verbosity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCobraArgumentError ¶
IsCobraArgumentError detects if an error is a Cobra argument validation error. These errors have already been printed by Cobra and should just return ExitCodeUsage.
func NewAdaptCommand ¶
func NewAdaptCommand(cfg *CommandConfig) *cobra.Command
NewAdaptCommand creates the adapt command with dependency injection.
func NewCanonicalizeCommand ¶
func NewCanonicalizeCommand(cfg *CommandConfig) *cobra.Command
NewCanonicalizeCommand creates the canonicalize command with dependency injection.
func NewCompletionCommand ¶
func NewCompletionCommand(_ *CommandConfig) *cobra.Command
NewCompletionCommand creates the completion command with shell subcommands. This replaces Cobra's default completion with Carapace's enhanced completion system.
func NewConfigCommand ¶ added in v0.9.0
func NewConfigCommand(cfg *CommandConfig) *cobra.Command
NewConfigCommand creates the config command group with init and validate subcommands.
func NewConfigInitCommand ¶ added in v0.9.0
func NewConfigInitCommand(cfg *CommandConfig) *cobra.Command
NewConfigInitCommand creates the config init command for scaffolding a new config file.
func NewConfigValidateCommand ¶ added in v0.9.0
func NewConfigValidateCommand(cfg *CommandConfig) *cobra.Command
NewConfigValidateCommand creates the config validate command for validating an existing config file.
func NewCreatePresetCommand ¶ added in v0.9.0
func NewCreatePresetCommand(cfg *CommandConfig, libraryPath *string) *cobra.Command
NewCreatePresetCommand creates the preset subcommand.
func NewInitCommand ¶
func NewInitCommand(cfg *CommandConfig) *cobra.Command
NewInitCommand creates the init command for installing resources from the library.
func NewLibraryAddCommand ¶ added in v0.9.0
func NewLibraryAddCommand(cfg *CommandConfig, libraryPath *string) *cobra.Command
NewLibraryAddCommand creates the library add subcommand.
func NewLibraryCommand ¶
func NewLibraryCommand(cfg *CommandConfig) *cobra.Command
NewLibraryCommand creates the library command with subcommands.
func NewLibraryCreateCommand ¶ added in v0.9.0
func NewLibraryCreateCommand(cfg *CommandConfig, libraryPath *string) *cobra.Command
NewLibraryCreateCommand creates the library create subcommand group.
func NewLibraryInitCommand ¶ added in v0.9.0
func NewLibraryInitCommand(cfg *CommandConfig) *cobra.Command
NewLibraryInitCommand creates the library init subcommand.
func NewLibraryPresetsCommand ¶
func NewLibraryPresetsCommand(cfg *CommandConfig, libraryPath *string) *cobra.Command
NewLibraryPresetsCommand creates the library presets subcommand.
func NewLibraryResourcesCommand ¶
func NewLibraryResourcesCommand(cfg *CommandConfig, libraryPath *string) *cobra.Command
NewLibraryResourcesCommand creates the library resources subcommand.
func NewLibraryShowCommand ¶
func NewLibraryShowCommand(cfg *CommandConfig, libraryPath *string) *cobra.Command
NewLibraryShowCommand creates the library show subcommand.
func NewRootCommand ¶
func NewRootCommand(cfg *CommandConfig) *cobra.Command
NewRootCommand creates the root command with all subcommands registered.
func NewValidateCommand ¶
func NewValidateCommand(cfg *CommandConfig) *cobra.Command
NewValidateCommand creates the validate command with dependency injection.
func NewVersionCommand ¶
func NewVersionCommand(_ *CommandConfig) *cobra.Command
NewVersionCommand creates a new version command.
func SetGlobalCommandConfig ¶
func SetGlobalCommandConfig(cfg *CommandConfig)
SetGlobalCommandConfig stores the CommandConfig for use in error handling. This is called during root command construction.
func VerbosePrint ¶
func VerbosePrint(cfg *CommandConfig, format string, args ...any)
VerbosePrint prints a message to stderr if verbosity is enabled.
func VeryVerbosePrint ¶
func VeryVerbosePrint(cfg *CommandConfig, format string, args ...any)
VeryVerbosePrint prints a detailed message to stderr if very verbose mode is enabled.
Types ¶
type CommandConfig ¶
type CommandConfig struct {
Services *ServiceContainer
ErrorFormatter *ErrorFormatter
Verbosity Verbosity
}
CommandConfig holds configuration and services for command execution.
type ErrorCategory ¶
type ErrorCategory int
ErrorCategory represents the category of an error.
const ( CategoryCobra ErrorCategory = iota CategoryConfig CategoryValidation CategoryTransform CategoryFile CategoryGit CategoryNotFound CategoryGeneric )
Error categories for classification.
func CategorizeError ¶
func CategorizeError(err error) ErrorCategory
CategorizeError determines the error category based on error type.
type ErrorFormatter ¶
type ErrorFormatter struct {
// contains filtered or unexported fields
}
ErrorFormatter formats errors based on their type.
func NewErrorFormatter ¶
func NewErrorFormatter() *ErrorFormatter
NewErrorFormatter creates a new ErrorFormatter with default formatters registered.
func (*ErrorFormatter) Format ¶
func (f *ErrorFormatter) Format(err error) string
Format returns a formatted string for the given error.
type ExitCode ¶
type ExitCode int
ExitCode represents the process exit code.
const ( ExitCodeSuccess ExitCode = 0 ExitCodeError ExitCode = 1 ExitCodeUsage ExitCode = 2 ExitCodeConfig ExitCode = 3 ExitCodeGit ExitCode = 4 ExitCodeValidation ExitCode = 5 ExitCodeNotFound ExitCode = 6 )
Exit codes for different error categories.
func GetExitCodeForError ¶
GetExitCodeForError returns the appropriate exit code for an error.
type ServiceContainer ¶
type ServiceContainer struct {
// Transformer handles document transformation.
Transformer application.Transformer
// Validator handles document validation.
Validator application.Validator
// Canonicalizer handles document canonicalization.
Canonicalizer application.Canonicalizer
// Initializer handles resource initialization.
Initializer application.Initializer
}
ServiceContainer holds service instances for dependency injection. It is passed through the command tree via CommandConfig.
func NewServiceContainer ¶
func NewServiceContainer() *ServiceContainer
NewServiceContainer creates a new ServiceContainer with all services initialized.
type ValidationResultError ¶
type ValidationResultError struct {
Errors []error
}
ValidationResultError wraps multiple validation errors for unified handling.
func (*ValidationResultError) Error ¶
func (e *ValidationResultError) Error() string
func (*ValidationResultError) Unwrap ¶
func (e *ValidationResultError) Unwrap() error
Unwrap returns the first error for compatibility with error chain support.