application

package
v0.1.0-dev.20260813053751 Latest Latest
Warning

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

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

Documentation

Overview

Package application defines the per-tool Application handle the workflow framework carries on its runtime environment.

Each tool (lore, star, writ, devlore-test) constructs an Application from its own CLI / config plumbing and hands it to the framework's runtime-environment spec at construction. The Application carries the variable resolver's input sources (flag / config / override maps) plus the tool's program name; the framework reads them uniformly without knowing tool specifics.

Flag projection uses cobra's pflag merged view: a single call to cobra.Command.Flags surfaces both the command's local flags and every persistent flag inherited from its ancestors. NewApplication walks that merged view via pflag.FlagSet.Visit, which yields only flags the user explicitly supplied on the command line — defaults are not stamped into Application.Flags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {

	// Name is the tool's program name (e.g., "lore", "star", "writ", "devlore-test").
	//
	// The framework's variable resolver derives its env-var prefix from this value as `strings.ToUpper(Name) + "_"`.
	Name string

	// Flags carries values parsed from command-line arguments.
	//
	// Consumed by the variable resolver as its flag source. Keys are snake-case (normalized from
	// cobra/pflag's kebab-case at [NewApplication] time so `--dry-run` lands under `Flags["dry_run"]`); values are the
	// typed Go value pflag parsed.
	//
	// Populated by [NewApplication] via [pflag.FlagSet.Visit] — only flags the user explicitly supplied are present. A
	// lookup for a flag the user did not pass returns the zero value via map-zero semantics.
	Flags map[string]any

	// Config carries values loaded from configuration files.
	//
	// Consumed by the variable resolver as its config source.
	Config map[string]any

	// Overrides carries programmatic-force values applied at highest precedence.
	//
	// Consumed by the variable resolver as its override source.
	Overrides map[string]any
}

Application is the tool-side handle the workflow framework reads through its runtime environment.

It carries the variable-resolver source maps and the tool's program name. Each tool owns its own instance and projects its native CLI / config plumbing into the three maps.

Flags, Config, and Overrides are passed verbatim to the framework's variable resolver when the runtime environment is constructed. Framework code that needs a specific flag (e.g., "dry-run") reads from Application.Flags directly without invoking the resolver.

func NewApplication

func NewApplication(name string, cmd *cobra.Command) *Application

NewApplication constructs an Application from a cobra command's parsed flag state.

Walks the command's merged pflag set (cobra merges persistent + local automatically when cobra.Command.Flags is called on the leaf) and stamps each user-supplied flag into Application.Flags under its snake-case form (cobra's kebab-case flag name with hyphens replaced by underscores). Defaults are not stamped.

The kebab→snake normalization makes Application.Flags uniform with the variable resolver's parameter-name conventions (snake_case throughout); the resolver's flag-source step matches the parameter name verbatim against the snake-case keys.

Config and Overrides are left nil. Tools that source either layer populate them via direct field assignment after construction.

Parameters:

  • `name`: the tool's program name (e.g., "lore", "writ").
  • `cmd`: the cobra command whose merged flag set drives Flags. Must be non-nil.

Returns:

  • *Application: the constructed Application with Name and Flags set.

func (*Application) DryRun

func (a *Application) DryRun() bool

DryRun reports whether the user supplied `--dry-run` on the active command.

Reads Application.Flags under the canonical snake-case key "dry_run" (normalized from cobra's "dry-run" at NewApplication time). Returns false when the flag was not supplied, when its value is not a bool, or when Application.Flags is nil.

Returns:

  • `bool`: true when `--dry-run` was supplied; false otherwise.

Jump to

Keyboard shortcuts

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