clix

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FromCommandFn = fromCommand

Functions

func GetOrInitVersionFile

func GetOrInitVersionFile(path string, strict bool) (bool, error)

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:

  1. If --path flag provided -> single-module mode
  2. If .sley.yaml has explicit path (not default) -> single-module mode
  3. If --all or --module flags -> multi-module mode (skip TUI)
  4. Detect context using workspace.Detector
  5. If MultiModule detected and interactive -> show TUI prompt
  6. 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.

Jump to

Keyboard shortcuts

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