Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var FromCommandFn = fromCommand
Functions ¶
func GetOrInitVersionFile ¶
GetOrInitVersionFile initializes the version file at the given path or checks for its existence based on the strict flag. It returns true if the file was created, false if it already existed. Returns a typed error (*apperrors.VersionFileNotFoundError) instead of cli.Exit.
Types ¶
type ExecutionContext ¶
type ExecutionContext struct {
// Mode indicates whether this is single or multi-module execution.
Mode ExecutionMode
// Path is the .version file path for single-module mode.
// Empty for multi-module mode.
Path string
// Modules contains the selected modules for multi-module mode.
// Nil for single-module mode.
Modules []*workspace.Module
// Selection contains the TUI selection result for multi-module mode.
// Used to determine if user selected all or specific modules.
Selection tui.Selection
}
ExecutionContext encapsulates the execution context for a command. It determines whether to operate on a single module or multiple modules based on flags, configuration, and user interaction.
func GetExecutionContext ¶
func GetExecutionContext(ctx context.Context, cmd *cli.Command, cfg *config.Config, opts ...ExecutionOption) (*ExecutionContext, error)
GetExecutionContext determines the execution context for a command. It follows this logic:
- If --path flag provided -> single-module mode
- If .sley.yaml has explicit path (not default) -> single-module mode
- If --all or --module flags -> multi-module mode (skip TUI)
- Detect context using workspace.Detector
- If MultiModule detected and interactive -> show TUI prompt
- If MultiModule detected and non-interactive (CI or --yes) -> auto-select all
The context parameter is used for cancellation and timeouts. The cmd parameter provides access to CLI flags. The cfg parameter provides workspace configuration. Optional ExecutionOption can be passed to modify behavior (e.g., WithDefaultAll).
func (*ExecutionContext) IsMultiModule ¶
func (ec *ExecutionContext) IsMultiModule() bool
IsMultiModule returns true if this is multi-module execution.
func (*ExecutionContext) IsSingleModule ¶
func (ec *ExecutionContext) IsSingleModule() bool
IsSingleModule returns true if this is single-module execution.
type ExecutionMode ¶
type ExecutionMode int
ExecutionMode indicates whether to operate on a single module or multiple modules.
const ( // SingleModuleMode indicates operating on a single .version file. SingleModuleMode ExecutionMode = iota // MultiModuleMode indicates operating on multiple .version files. MultiModuleMode )
func (ExecutionMode) String ¶
func (m ExecutionMode) String() string
String returns a string representation of the execution mode.
type ExecutionOption ¶
type ExecutionOption func(*executionOptions)
ExecutionOption configures execution context behavior.
func WithDefaultAll ¶
func WithDefaultAll() ExecutionOption
WithDefaultAll configures the execution context to default to all modules without showing a TUI prompt. Use this for read-only commands like "show" and "doctor" where prompting adds friction without value.