Documentation
¶
Overview ¶
Package cli defines the Cobra command surface for the divekit tool
Index ¶
- Constants
- Variables
- func Execute() error
- func NewRootCmd() *cobra.Command
- func RegisterGUIRuntime(run guiRuntimeFunc)
- func SetCmdFlags(cmd *cobra.Command)
- func WaitForBackgroundTasks(timeout time.Duration)
- type CommandError
- func NewCommandError(errorType ErrorType, message string, err error) *CommandError
- func NewConflictingFlagsError(details string) *CommandError
- func NewDistributionNotFoundError(distributionName string) *CommandError
- func NewExecutionFailedError(operation string, err error) *CommandError
- func NewHandlerCreationFailedError(handlerType string, err error) *CommandError
- func NewHandlerSetupFailedError(err error) *CommandError
- func NewHandlerValidationFailedError(err error) *CommandError
- func NewHomeInitError(err error) *CommandError
- func NewLogLevelDefinitionError(err error) *CommandError
- func NewMembersExecutionFailedError(operation string, err error) *CommandError
- func NewNoDistributionsFoundError(workingDir string) *CommandError
- func NewProposalFailedError(err error) *CommandError
- type ErrorContext
- type ErrorType
- type GUIRuntimeNotLinkedError
- type InvalidArgsError
- func (e *InvalidArgsError) Category() apperror.Category
- func (e *InvalidArgsError) Cause() error
- func (e *InvalidArgsError) Details() map[string]any
- func (e *InvalidArgsError) Error() string
- func (e *InvalidArgsError) ExitCode() int
- func (e *InvalidArgsError) IsCritical() bool
- func (e *InvalidArgsError) Retryable() bool
- func (e *InvalidArgsError) UserMessage() string
Constants ¶
const ( MsgConflictingFlags = "Conflicting options specified" MsgNoDistributionsFound = "No distributions found in this directory" MsgDistributionNotFound = "Distribution not found" MsgHandlerCreationFailed = "Could not initialize command" MsgHandlerSetupFailed = "Setup failed" MsgHandlerValidationFailed = "Configuration is invalid" MsgProposalFailed = "Could not prepare changes" MsgExecutionFailed = "Command execution failed" )
User-friendly error messages
Variables ¶
var ( // LogLevelFlag mirrors the parsed root log level for legacy command code. LogLevelFlag = defaultRootLogLevel // NonInteractiveFlag mirrors parsed non-interactive mode for legacy command code. NonInteractiveFlag bool // AssumeYesFlag mirrors parsed assume-yes mode for legacy command code. AssumeYesFlag bool // NoIndexFlag mirrors parsed index opt-out for legacy command code. NoIndexFlag bool )
var ( // IndexCmd represents the base command for all index operations. IndexCmd = &cobra.Command{ Use: "index", Short: "Manage the Divekit project index", Long: `Manage the local project index for fast project discovery and search. The project index is a local database that tracks Divekit projects and their distributions. It enables fast searching and navigation between projects. SUBCOMMANDS: add Add projects to the index refresh Verify and update all indexed projects`, Example: ` # Add current directory to index divekit index add # Add a specific project divekit index add /path/to/project # Recursively find and add all projects divekit index add --recursive # Find sibling projects (go up one dir, scan siblings) divekit index add --siblings # Refresh the entire index (verify paths, update distributions) divekit index refresh`, } )
Functions ¶
func Execute ¶
func Execute() error
Execute runs the root command and handles any errors that occur during execution. This is the main entry point called from main() and will start the cobra command parsing and execution process.
func NewRootCmd ¶
NewRootCmd creates and returns the root command for the divekit CLI application. This command serves as the entry point for all divekit operations including repository initialization, distribution, patching, and management.
func RegisterGUIRuntime ¶
func RegisterGUIRuntime(run guiRuntimeFunc)
RegisterGUIRuntime installs the GUI runtime implementation for executable builds. Consumer tools such as doc generators can import internal/cli without linking the GUI runtime.
func SetCmdFlags ¶
SetCmdFlags configures the persistent flags for the given cobra command. It sets up global flags including log level and non-interactive mode that apply to all subcommands in the divekit CLI.
func WaitForBackgroundTasks ¶
WaitForBackgroundTasks waits for all background goroutines to complete with the specified timeout. If the timeout is reached, it logs a warning and returns without waiting further.
Types ¶
type CommandError ¶
type CommandError struct {
apperror.Carrier
ErrorType ErrorType
Message string
Err error // Wrapped error
Context *ErrorContext // Optional additional context
}
CommandError represents a specific error in the internal/cli package
func NewCommandError ¶
func NewCommandError(errorType ErrorType, message string, err error) *CommandError
NewCommandError creates a new CommandError
func NewConflictingFlagsError ¶
func NewConflictingFlagsError(details string) *CommandError
NewConflictingFlagsError creates a new conflicting flags error
func NewDistributionNotFoundError ¶
func NewDistributionNotFoundError(distributionName string) *CommandError
NewDistributionNotFoundError creates a new distribution not found error
func NewExecutionFailedError ¶
func NewExecutionFailedError(operation string, err error) *CommandError
NewExecutionFailedError creates a new execution failed error
func NewHandlerCreationFailedError ¶
func NewHandlerCreationFailedError(handlerType string, err error) *CommandError
NewHandlerCreationFailedError creates a new handler creation failed error
func NewHandlerSetupFailedError ¶
func NewHandlerSetupFailedError(err error) *CommandError
NewHandlerSetupFailedError creates a new handler setup failed error
func NewHandlerValidationFailedError ¶
func NewHandlerValidationFailedError(err error) *CommandError
NewHandlerValidationFailedError creates a new handler validation failed error
func NewHomeInitError ¶
func NewHomeInitError(err error) *CommandError
NewHomeInitError creates a new error for divekit home directory initialization failures
func NewLogLevelDefinitionError ¶
func NewLogLevelDefinitionError(err error) *CommandError
NewLogLevelDefinitionError creates a new error for logging level definition failures
func NewMembersExecutionFailedError ¶
func NewMembersExecutionFailedError(operation string, err error) *CommandError
NewMembersExecutionFailedError creates a members-specific execution error.
func NewNoDistributionsFoundError ¶
func NewNoDistributionsFoundError(workingDir string) *CommandError
NewNoDistributionsFoundError creates a new no distributions found error
func NewProposalFailedError ¶
func NewProposalFailedError(err error) *CommandError
NewProposalFailedError creates a new proposal failed error
func (*CommandError) Error ¶
func (e *CommandError) Error() string
Error implements the error interface
func (*CommandError) Unwrap ¶
func (e *CommandError) Unwrap() error
Unwrap returns the wrapped cause for errors.Is/As support
func (*CommandError) WithContext ¶
func (e *CommandError) WithContext(ctx ErrorContext) *CommandError
WithContext adds context to the error and returns a new CommandError
type ErrorContext ¶
ErrorContext provides additional context for errors
type ErrorType ¶
type ErrorType int
ErrorType defines the different types of errors in the internal/cli package
type GUIRuntimeNotLinkedError ¶
type GUIRuntimeNotLinkedError struct{}
GUIRuntimeNotLinkedError indicates that the GUI command was built without its runtime implementation.
func (*GUIRuntimeNotLinkedError) Error ¶
func (e *GUIRuntimeNotLinkedError) Error() string
Error implements the error interface.
type InvalidArgsError ¶
type InvalidArgsError struct {
Msg string
}
InvalidArgsError represents an error that occurs when invalid arguments are provided to a divekit command. It wraps the error message for consistent error handling across the CLI.
func (*InvalidArgsError) Category ¶
func (e *InvalidArgsError) Category() apperror.Category
Category classifies invalid CLI arguments as user-correctable validation errors.
func (*InvalidArgsError) Cause ¶
func (e *InvalidArgsError) Cause() error
Cause returns the underlying error cause.
func (*InvalidArgsError) Details ¶
func (e *InvalidArgsError) Details() map[string]any
Details returns structured error metadata.
func (*InvalidArgsError) Error ¶
func (e *InvalidArgsError) Error() string
Error returns the error message associated with the InvalidArgsError.
func (*InvalidArgsError) ExitCode ¶
func (e *InvalidArgsError) ExitCode() int
ExitCode returns the standard validation failure exit code.
func (*InvalidArgsError) IsCritical ¶
func (e *InvalidArgsError) IsCritical() bool
IsCritical reports whether this error should stop command execution.
func (*InvalidArgsError) Retryable ¶
func (e *InvalidArgsError) Retryable() bool
Retryable reports whether retrying without changing input is useful.
func (*InvalidArgsError) UserMessage ¶
func (e *InvalidArgsError) UserMessage() string
UserMessage returns the message shown to CLI users.
Source Files
¶
- auth.go
- ci.go
- command_flags.go
- config.go
- config_explain.go
- config_flags.go
- config_hosts.go
- config_hosts_render.go
- config_hosts_run.go
- config_origin.go
- config_origin_render.go
- config_origin_run.go
- config_render.go
- dev.go
- dev_flags.go
- distribute.go
- distribute_flags.go
- doctor.go
- error.go
- feedback.go
- feedback_flags.go
- feedback_format.go
- feedback_interactive.go
- feedback_member_prompts.go
- feedback_members.go
- feedback_prompt_adapters.go
- feedback_request.go
- feedback_run.go
- fetch.go
- fetch_flags.go
- gui.go
- gui_flags.go
- index.go
- index_add.go
- index_add_flags.go
- index_refresh.go
- init.go
- inject.go
- inject_flags.go
- install.go
- internal.go
- internal_report_preview.go
- internal_ui_preview.go
- internal_ui_preview_flags.go
- members.go
- members_alias.go
- members_flags.go
- members_init.go
- members_input.go
- members_list.go
- members_output.go
- members_progress.go
- members_progress_bar.go
- members_progress_model.go
- members_show.go
- members_sync.go
- members_sync_missing_output.go
- members_update_commands.go
- members_validate.go
- overview.go
- overview_flags.go
- passcheck.go
- patch.go
- patch_ci.go
- patch_feedback.go
- patch_feedback_confirm.go
- patch_feedback_execute.go
- patch_feedback_progress.go
- patch_feedback_targets.go
- patch_file_picker.go
- patch_flags.go
- patch_name.go
- patch_name_diff.go
- patch_name_plan.go
- patch_name_progress.go
- patch_name_result.go
- patch_run.go
- plugin.go
- plugin_add_update_commands.go
- plugin_basic_commands.go
- plugin_configure.go
- plugin_configure_object_list.go
- plugin_configure_paths.go
- plugin_configure_prompts.go
- plugin_configure_scalar_values.go
- plugin_configure_values.go
- plugin_discover_command.go
- plugin_flags.go
- plugin_format.go
- plugin_interactive.go
- plugin_override.go
- plugin_override_apply.go
- plugin_override_interactive.go
- plugin_runtime.go
- plugin_source_commands.go
- plugin_wizard_preview.go
- plugin_wizard_preview_default.go
- plugin_wizard_preview_gallery.go
- purge.go
- purge_flags.go
- report.go
- role.go
- role_flags.go
- root.go
- root_commands.go
- root_execute.go
- root_invalid_args.go
- root_setup.go
- run.go
- run_flags.go
- run_init.go
- run_init_input.go
- search.go
- search_flags.go
- snapshot.go
- snapshot_flags.go
- snapshot_progress.go
- uninstall.go
- uninstall_flags.go
- update.go
- update_flags.go
- version.go