cmd

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FORMAT_INI  = "ini"
	FORMAT_YAML = "yaml"
	FORMAT_TOML = "toml"
	FORMAT_JSON = "json"
	FORMAT_XML  = "xml"
)

File format constants

View Source
const (
	PKG_CMD  = "cmd"
	APP_NAME = "confedit"
)

Variables

This section is empty.

Functions

func Run

func Run(version string, args []string) error

Run executes the CLI with the given version

Types

type ApplyCmd

type ApplyCmd struct {
	Targets []string `arg:"" optional:"" help:"Rest of the arguments are a list of target names"`
	Force   bool     `help:"Force apply even if validation fails"`
	Backup  bool     `help:"Create backup of files before modification" default:"true"`
}

ApplyCmd performs edit operations on given files

func (*ApplyCmd) Run

func (c *ApplyCmd) Run(ctx *kong.Context, cli *CLI) error

type CLI

type CLI struct {
	Globals  `kong:"embed"`
	Version  VersionCmd  `cmd:"" help:"Show version information"`
	Apply    ApplyCmd    `cmd:"" help:"Apply changes to target system"`
	Status   StatusCmd   `cmd:"" help:"Check status on target system"`
	List     ListCmd     `cmd:"" help:"List defined targets"`
	Generate GenerateCmd `cmd:"" help:"Generate CUE data from diff between source and target of specified type"`
}

CLI represents the main CLI structure

func (*CLI) AfterApply

func (cli *CLI) AfterApply(ctx *kong.Context) error

AfterApply is called after Kong parses the CLI but before the command runs

type CommandContext

type CommandContext struct {
	StateManager *state.Manager
	Reconciler   reconciler.Reconciler
	Loader       *loader.CueDataLoader
	SystemConfig *types.SystemConfig
	Targets      []types.AnyTarget
	HookExecutor *reconciler.HookExecutor
}

CommandContext holds the shared initialization components for apply and status commands

func InitializeCommand

func InitializeCommand(cli *CLI, currentTargets []string, dryRunOverride *bool, backupOverride *bool) (*CommandContext, error)

InitializeCommand performs common initialization for apply and status commands

type GenerateCmd

type GenerateCmd struct {
	Source      []string `arg:"" help:"Source and target executor specifications (format: type:path)"`
	Type        string   `short:"t" required:"" help:"Type of the target executor" enum:"file,dconf,systemd,sed"`
	Name        string   `short:"n" help:"Name for the generated target"`
	Output      string   `short:"o" help:"Output file path for the generated .cue data"`
	Identifiers string   `help:"Target identifiers in flattened format (e.g., options.use_spacing=true,backup=false,metadata.custom=value)"`
	FileFormat  string   `` /* 132-byte string literal not displayed */
	// contains filtered or unexported fields
}

GenerateCmd generates a .cue data file from the diff between two executor targets

func (*GenerateCmd) Run

func (c *GenerateCmd) Run(ctx *kong.Context, cli *CLI) error

type Globals

type Globals struct {
	LogLevel  string `help:"Log level (trace,debug,info,warn,error)" default:"info"`
	LogFormat string `help:"Log format (console,json)" default:"console"`
	DryRun    bool   `help:"Show what would be deleted without actually editing" default:"false"`
	Config    string `short:"c" help:"Path to CUE data file or directory" default:"config/"`
	Schema    string `help:"Path to alternative CUE schema file. This will override the embedded schema. Use mainly for developing schema changes."`
	StateDir  string `help:"Directory for state storage. Not yet used." default:".state/"`
}

type ListCmd

type ListCmd struct {
	Long   bool   `short:"l" help:"Show detailed information about targets"`
	Format string `short:"f" default:"table" enum:"table,json,yaml" help:"Output format (table, json, yaml)"`
}

ListCmd lists targets

func (*ListCmd) Run

func (c *ListCmd) Run(ctx *kong.Context, cli *CLI) error

type StatusCmd

type StatusCmd struct {
	Targets []string `arg:"" optional:"" help:"Rest of the arguments are a list of target names"`
}

StatusCmd performs status checks on the target system

func (*StatusCmd) Run

func (c *StatusCmd) Run(ctx *kong.Context, cli *CLI) error

type VersionCmd

type VersionCmd struct{}

VersionCmd shows version information

func (*VersionCmd) Run

func (v *VersionCmd) Run(name, version string) error

Jump to

Keyboard shortcuts

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