ui

package
v1.227.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileOutputPath added in v1.227.0

func FileOutputPath(file tmpl.File, spec config.FileSpec) string

FileOutputPath resolves the output path template for one discovered file: spec.Target when set, otherwise the file's own discovered Path. See docs/prd/atmos-scaffold.md, "Dynamic File Generation (matrix)". Exported (alongside FileSpecByPath/ResolveDelimiters) so callers that need to plan output paths without running generation -- e.g. cmd/scaffold's dry-run preview -- resolve Target the same way real generation does instead of duplicating this one-line rule.

func FileSpecByPath added in v1.227.0

func FileSpecByPath(scaffoldConfig *config.ScaffoldConfig) map[string]config.FileSpec

FileSpecByPath indexes a scaffold config's spec.files overlay by declared path, for O(1) lookup during the file-generation loop. Files not listed in the overlay generate unconditionally with no Target/Matrix override -- FileSpec's zero-value When already evaluates to true (see condition.Condition.Evaluate). Exported so the `--dry-run` preview (cmd/scaffold) can gate its file list with the exact same spec.When evaluation real generation uses, instead of a second, divergent copy.

func ResolveDelimiters added in v1.227.0

func ResolveDelimiters(delimiters []string, scaffoldConfig *config.ScaffoldConfig) []string

ResolveDelimiters determines the delimiters to use. A scaffold config's own declared delimiters always win: callers (Execute/ExecuteWithBaseRef) pass a generic "{{"/"}}" default through regardless of what the scaffold actually declares, so treating that default as an explicit override would silently ignore scaffold.yaml's spec.delimiters (e.g. "[[" / "]]") -- this is exactly what engine.extractDelimiters already does for per-file rendering via ProcessFile, which ResolveDelimiters must match so the README summary renders with the same delimiters as every other generated file.

Types

type InitUI

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

InitUI handles the user interface for the init command.

func NewInitUI

func NewInitUI(ioCtx iolib.Context, term terminal.Terminal) *InitUI

NewInitUI creates a new InitUI instance.

func (*InitUI) ConfirmUpdateInstead

func (ui *InitUI) ConfirmUpdateInstead(targetPath string) (bool, error)

ConfirmUpdateInstead prompts whether to update an existing, non-empty target directory via a 3-way merge instead of failing outright. Callers should only invoke this after confirming a real TTY is available for prompting.

func (*InitUI) DisplayScaffoldTemplateTable

func (ui *InitUI) DisplayScaffoldTemplateTable(templatesMap map[string]interface{})

DisplayScaffoldTemplateTable displays scaffold templates in a table format.

func (*InitUI) DisplayTemplateTable

func (ui *InitUI) DisplayTemplateTable(header []string, rows [][]string)

DisplayTemplateTable displays template data in a formatted table.

func (*InitUI) Execute

func (ui *InitUI) Execute(embedsConfig *tmpl.Configuration, targetPath string, force, update, useDefaults bool, cmdTemplateValues map[string]interface{}) error

Execute runs the initialization process with UI.

func (*InitUI) ExecuteWithBaseRef

func (ui *InitUI) ExecuteWithBaseRef(embedsConfig *tmpl.Configuration, targetPath string, force, update, useDefaults bool, baseRef string, cmdTemplateValues map[string]interface{}) error

ExecuteWithBaseRef runs the initialization process with UI and specified base ref.

func (*InitUI) ExecuteWithDelimiters

func (ui *InitUI) ExecuteWithDelimiters(embedsConfig *tmpl.Configuration, targetPath string, force, update, useDefaults bool, baseRef string, cmdTemplateValues map[string]interface{}, delimiters []string) error

ExecuteWithDelimiters runs the initialization process with UI and custom delimiters.

func (*InitUI) ExecuteWithInteractiveFlow

func (ui *InitUI) ExecuteWithInteractiveFlow(
	embedsConfig *tmpl.Configuration,
	targetPath string,
	force, update, useDefaults bool,
	cmdTemplateValues map[string]interface{},
) error

ExecuteWithInteractiveFlow provides a unified flow for both init and scaffold commands. This ensures both commands have identical behavior - the only difference is the source of templates.

func (*InitUI) ExecuteWithInteractiveFlowAndBaseRef

func (ui *InitUI) ExecuteWithInteractiveFlowAndBaseRef(
	embedsConfig *tmpl.Configuration,
	targetPath string,
	force, update, useDefaults bool,
	baseRef string,
	cmdTemplateValues map[string]interface{},
) error

ExecuteWithInteractiveFlowAndBaseRef provides a unified flow with base ref support.

func (*InitUI) ExecuteWithInteractiveFlowAndBaseRefResult

func (ui *InitUI) ExecuteWithInteractiveFlowAndBaseRefResult(
	embedsConfig *tmpl.Configuration,
	targetPath string,
	force, update, useDefaults bool,
	baseRef string,
	cmdTemplateValues map[string]interface{},
) (string, error)

ExecuteWithInteractiveFlowAndBaseRefResult provides the interactive flow with base ref support and returns the final target path.

func (*InitUI) ExecuteWithInteractiveFlowResult

func (ui *InitUI) ExecuteWithInteractiveFlowResult(
	embedsConfig *tmpl.Configuration,
	targetPath string,
	force, update, useDefaults bool,
	cmdTemplateValues map[string]interface{},
) (string, error)

ExecuteWithInteractiveFlowResult provides the same flow as ExecuteWithInteractiveFlow and returns the final target path selected by the user.

func (*InitUI) GetTerminalWidth

func (ui *InitUI) GetTerminalWidth() int

GetTerminalWidth returns the current terminal width with a fallback.

func (*InitUI) PromptForTargetDirectory

func (ui *InitUI) PromptForTargetDirectory(templateInfo interface{}, mergedValues map[string]interface{}) (string, error)

PromptForTargetDirectory prompts the user for the target directory with evaluated template values This works for both init and scaffold commands.

func (*InitUI) PromptForTemplate

func (ui *InitUI) PromptForTemplate(templateType string, templates interface{}) (string, error)

PromptForTemplate prompts the user to select a template from available options. This works for both init (embeds) and scaffold (local/remote) templates.

func (*InitUI) ResolveTargetPath added in v1.227.0

func (ui *InitUI) ResolveTargetPath(
	embedsConfig *tmpl.Configuration,
	targetPath string,
	update, useDefaults bool,
	cmdTemplateValues map[string]interface{},
) (string, map[string]interface{}, bool, error)

ResolveTargetPath determines the target path to generate into, prompting interactively (and reconciling any values pre-collected during that prompt) when the caller did not already provide one. It is exported so callers that need the final target directory *before* calling one of the ExecuteWithInteractiveFlow* variants (for example to resolve a --update base ref against the real target rather than the empty path available before the interactive prompt runs) can resolve it themselves first -- passing the result back in as targetPath short-circuits the prompt on the subsequent Execute* call, since resolveTargetPath is a no-op once targetPath is non-empty.

func (*InitUI) RunSetupForm

func (ui *InitUI) RunSetupForm(scaffoldConfig *config.ScaffoldConfig, targetPath string, useDefaults bool, cmdTemplateValues map[string]interface{}) (map[string]interface{}, map[string]string, error)

RunSetupForm runs the interactive setup form to collect configuration values This method can be used by both init and scaffold commands.

func (*InitUI) SetConflictStrategy

func (ui *InitUI) SetConflictStrategy(strategy merge.ConflictStrategy)

SetConflictStrategy sets how a real ours/theirs divergence is resolved during a 3-way merge (manual/ours/theirs). The zero value (merge.ConflictStrategyManual) is today's existing behavior.

func (*InitUI) SetDryRun

func (ui *InitUI) SetDryRun(dryRun bool)

SetDryRun toggles dry-run mode: rendering and 3-way merge still run (so real conflicts are reported), but no files are written to disk.

func (*InitUI) SetMergeDriver added in v1.226.0

func (ui *InitUI) SetMergeDriver(driver merge.Driver)

SetMergeDriver sets which merger handles every file during a 3-way merge.

func (*InitUI) SetSkipHooks

func (ui *InitUI) SetSkipHooks(skip func(string) bool)

SetSkipHooks configures the --skip-hooks predicate (see hooks.NewSkipPredicate) consulted before running any scaffold hook. A nil predicate (the zero value) runs every hook, matching today's behavior for templates that don't set one.

func (*InitUI) SetThreshold

func (ui *InitUI) SetThreshold(thresholdPercent int)

SetThreshold sets the threshold for merge operations.

Jump to

Keyboard shortcuts

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