Documentation
¶
Overview ¶
Package cmd implements the dotdrift command-line interface and its subcommands.
Index ¶
- func Run(version string, args []string) error
- type ApplyCmd
- type CLI
- type DetectCmd
- type GenerateCmd
- type GenerateMountsCmd
- type GenerateSmbCmd
- type InitCmd
- type ModulesCmd
- type OnboardCmd
- type ParuCmd
- type ParuInstallCmd
- type ParuInstalledCmd
- type PlanCmd
- type RestoreCmd
- type RootFlags
- type StatusCmd
- type VersionCmd
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApplyCmd ¶
type ApplyCmd struct {
Profile string `help:"Path to profile directory" type:"existingdir" default:"."`
State string `help:"Path to state file" type:"path" default:""`
Yes bool `help:"Answer yes to mise prompts" default:"false"`
Verbose bool `` /* 139-byte string literal not displayed */
Diff string `` /* 130-byte string literal not displayed */
Backup bool `` /* 193-byte string literal not displayed */
Modules []string `arg:"" optional:"" name:"modules" help:"Limit scope to these modules (space or comma separated)"`
Out io.Writer `kong:"-"`
// Section flags: positives select exactly those sections, negatives
// (--no-<section>) subtract, no flags runs everything. Each maps to
// the same-named module.toml plan section. No default:"false" tag —
// an explicit default marks the flag Set in kong, which would defeat
// presence detection (positive vs negated vs absent). The group tag
// renders all six under one "Section flags" heading in --help.
Packages bool `group:"Section flags" help:"Apply only the packages section" negatable:""`
Tools bool `group:"Section flags" help:"Apply only the tools section" negatable:""`
Dotfiles bool `group:"Section flags" help:"Apply only the dotfiles section (user + system)" negatable:""`
Mounts bool `group:"Section flags" help:"Apply only the mounts section (units + services + destination dirs)" negatable:""`
Smb bool `group:"Section flags" help:"Apply only the smb section" negatable:""`
Hooks bool `group:"Section flags" help:"Run pre/post hook commands" negatable:""`
// contains filtered or unexported fields
}
ApplyCmd runs the full pipeline and always resumes.
func (*ApplyCmd) AfterApply ¶ added in v0.23.0
AfterApply captures the parse context so Run can read which section flags were explicitly set (positive or negated) — a plain bool field cannot distinguish `--hooks` from an untouched default.
type CLI ¶
type CLI struct {
RootFlags `kong:"embed"`
Init InitCmd `cmd:"" help:"Create or clone a profile"`
Detect DetectCmd `cmd:"" help:"Detect system facts"`
Modules ModulesCmd `cmd:"" help:"List selected and skipped modules"`
Plan PlanCmd `cmd:"" help:"Print the effective plan"`
Apply ApplyCmd `cmd:"" help:"Apply the profile"`
Status StatusCmd `cmd:"" help:"Show status"`
Onboard OnboardCmd `cmd:"" help:"Onboard paths into a module" aliases:"add,adopt"`
Restore RestoreCmd `cmd:"" help:"Restore copy-mode targets from module backups"`
Generate GenerateCmd `cmd:"" help:"Generate mounts/smb modules"`
Paru ParuCmd `cmd:"" help:"paru mise plugin backend (internal)"`
Version VersionCmd `cmd:"" help:"Show version information"`
// contains filtered or unexported fields
}
CLI is the root command structure for dotdrift.
type DetectCmd ¶
type DetectCmd struct {
Out io.Writer `kong:"-"`
// OSReader and GPUReader allow tests to inject fakes. When nil, real system
// readers are used.
OSReader detect.OSReleaseReader `kong:"-"`
GPUReader detect.GPUReader `kong:"-"`
}
DetectCmd prints system facts.
type GenerateCmd ¶ added in v0.2.0
type GenerateCmd struct {
Mounts GenerateMountsCmd `cmd:"" help:"Generate a mounts module (systemd units)"`
Smb GenerateSmbCmd `cmd:"" help:"Generate an smb module (samba shares)"`
}
GenerateCmd groups the module generators.
type GenerateMountsCmd ¶ added in v0.2.0
type GenerateMountsCmd struct {
Profile string `help:"Path to profile directory" type:"existingdir" default:"."`
Layer string `help:"Target layer" enum:"base,host,user" default:"base"`
Module string `help:"Module id" default:"mounts"`
Hostname string `help:"Hostname for --layer host (default: detected)"`
Username string `help:"Username for --layer user (default: detected)"`
Name string `help:"Mount name (input flag)"`
Source string `help:"Mount source, e.g. UUID=<uuid> or server:/export (input flag)"`
Destination string `help:"Mount destination path (input flag)"`
Type string `help:"Filesystem type; the registry preset applies when --option is omitted (input flag)"`
Option []string `help:"Mount option (repeatable; overrides the registry preset for --type)"`
StartAt string `name:"startat" help:"OnCalendar expression; adds a .timer/.service pair (input flag)"`
State string `help:"Mount state: enabled or disabled (default enabled)"`
ListVolumes bool `name:"list-volumes" help:"Print detected volumes and exit"`
TUI *bool `negatable:"" help:"Force the interactive wizard (--no-tui forces CLI mode)"`
Out io.Writer `kong:"-"`
}
GenerateMountsCmd generates a mounts module: systemd .mount units (plus .service/.timer pairs for --startat) and the module.toml scope, [mounts] section, packages, and dotfile entries that place them.
func (*GenerateMountsCmd) Run ¶ added in v0.2.0
func (c *GenerateMountsCmd) Run() error
Run implements the mounts generator: mode selection, then either the volume table, the wizard, or CLI-mode assembly + WriteModule.
type GenerateSmbCmd ¶ added in v0.2.0
type GenerateSmbCmd struct {
Profile string `help:"Path to profile directory" type:"existingdir" default:"."`
Layer string `help:"Target layer" enum:"base,host,user" default:"base"`
Module string `help:"Module id" default:"smb"`
Hostname string `help:"Hostname for --layer host (default: detected)"`
Username string `help:"Username for --layer user (default: detected)"`
Group string `help:"Samba group (default \"smb\"; input flag)"`
Users []string `name:"user" help:"Samba user (repeatable; default: the invoking user)"`
Avahi *bool `negatable:"" help:"Avahi service discovery (default on; --no-avahi records an explicit off)"`
Writable *bool `negatable:"" help:"Shares writable (default on; input flag)"`
Readonly bool `help:"Shares read-only: sets writable=false"`
Public bool `help:"Shares public (guest access; input flag)"`
TUI *bool `negatable:"" help:"Force the interactive wizard (--no-tui forces CLI mode)"`
Out io.Writer `kong:"-"`
}
GenerateSmbCmd generates an smb module: shares.conf, a one-time smb.conf seed, and the module.toml scope, smb section, packages, and dotfile entries that place them.
func (*GenerateSmbCmd) Run ¶ added in v0.2.0
func (c *GenerateSmbCmd) Run() error
Run implements the smb generator.
type InitCmd ¶
type InitCmd struct {
Path string `arg:"" help:"Local path or git URL for the profile" default:"."`
}
InitCmd creates or clones a profile.
type ModulesCmd ¶
type ModulesCmd struct {
Profile string `help:"Path to profile directory" type:"existingdir" default:"."`
Modules []string `arg:"" optional:"" name:"modules" help:"Limit scope to these modules (space or comma separated)"`
Out io.Writer `kong:"-"`
}
ModulesCmd lists selected and skipped modules for a profile.
func (*ModulesCmd) Run ¶
func (c *ModulesCmd) Run() error
Run loads the profile and prints selection status.
type OnboardCmd ¶
type OnboardCmd struct {
Paths []string `arg:"" optional:"" help:"Paths to onboard into the module"`
Profile string `help:"Path to profile directory" type:"existingdir" default:"."`
App string `help:"Module directory name (inferred from the first path when omitted)"`
Mode string `help:"Dotfile mode" enum:"symlink,symlink-each,copy,template" default:"symlink"`
Packages []string `help:"Distro packages to declare; each entry is a bare name or name=\"description\" (the description becomes a TOML comment)"`
Tools []string `help:"Mise tools to declare"`
Host overlayFlag `help:"Onboard into hosts/<hostname>; no value = current host, --host=<name> = explicit, flag omitted = base layer"`
User overlayFlag `help:"Onboard into users/<username>; no value = current user, --user=<name> = explicit, flag omitted = base layer"`
DryRun bool `help:"Preview only"`
Yes bool `help:"Answer yes to mise prompts" default:"false"`
Verbose bool `` /* 139-byte string literal not displayed */
// Mise injects a runner for tests; nil uses the real mise bootstrap.
Mise mise.Runner `kong:"-"`
}
OnboardCmd copies live paths into a module and applies them.
type ParuCmd ¶ added in v0.10.0
type ParuCmd struct {
Installed ParuInstalledCmd `cmd:"" help:"Check package install status (plugin backend)"`
Install ParuInstallCmd `cmd:"" help:"Install packages via paru (plugin backend)"`
}
ParuCmd is the dotdrift mise package-plugin backend for the `paru` manager. These subcommands are invoked by the Lua plugin shim, not by end users directly. They are thin wrappers over internal/paru.
type ParuInstallCmd ¶ added in v0.10.0
type ParuInstallCmd struct {
Names []string `arg:"" optional:"" help:"Package names to install"`
DryRun bool `name:"dry-run" help:"Print what would happen without running"`
Update bool `help:"Refresh package manager metadata first"`
}
ParuInstallCmd installs packages via paru -S --needed --noconfirm.
func (*ParuInstallCmd) Run ¶ added in v0.10.0
func (c *ParuInstallCmd) Run() error
type ParuInstalledCmd ¶ added in v0.10.0
type ParuInstalledCmd struct {
Names []string `arg:"" optional:"" help:"Package names to check"`
}
ParuInstalledCmd checks package status via pacman -Q and emits the line protocol consumed by the Lua plugin shim.
func (*ParuInstalledCmd) Run ¶ added in v0.10.0
func (c *ParuInstalledCmd) Run() error
type PlanCmd ¶
type PlanCmd struct {
Profile string `help:"Path to profile directory" type:"existingdir" default:"."`
JSON bool `short:"j" help:"Print the plan as a single JSON object (suppresses the text rendering and warnings)"`
Deps bool `help:"Show dependency tree for packages in the install list"`
DepsDepth int `default:"1" help:"Dependency recursion depth (requires --deps)"`
Modules []string `arg:"" optional:"" name:"modules" help:"Limit scope to these modules (space or comma separated)"`
Facts *facts.Facts `kong:"-"`
Out io.Writer `kong:"-"`
}
PlanCmd prints the resolved plan without side effects.
type RestoreCmd ¶ added in v0.26.0
type RestoreCmd struct {
Targets []string `arg:"" optional:"" name:"targets" help:"Live target paths to restore (absolute or ~/), as they were when backed up"`
Profile string `help:"Path to profile directory" type:"existingdir" default:"."`
Gen string `` /* 126-byte string literal not displayed */
DryRun bool `help:"List what would be restored without touching anything"`
List bool `help:"List backup generations (per module, or the generations holding the given targets) and exit"`
Out io.Writer `kong:"-"`
}
RestoreCmd copies backed-up copy-mode destinations back to their live targets (the inverse of apply --backup).
func (*RestoreCmd) Run ¶ added in v0.26.0
func (c *RestoreCmd) Run() error
Run implements the restore command.
type RootFlags ¶
type RootFlags struct {
LogLevel string `help:"Log level (trace,debug,info,warn,error)" enum:"trace,debug,info,warn,error" default:"info" env:"LOG_LEVEL"`
LogFormat string `help:"Log format (console,json)" enum:"console,json" default:"console" env:"LOG_FORMAT"`
PProf bool `help:"Enable pprof profiling server" default:"false"`
PProfListenOn string `help:"Listen address for pprof profiling server" default:"127.0.0.1:6060"`
NoColor bool `help:"Disable colored output" default:"false" env:"NO_COLOR"`
}
RootFlags holds global CLI flags.
type StatusCmd ¶
type StatusCmd struct {
Profile string `help:"Path to profile directory" type:"existingdir" default:"."`
State string `help:"Path to state file" type:"path" default:""`
Verbose bool `help:"Show each probe as it starts ('checking <section>: <item>') on stderr" short:"v" default:"false"`
Jobs int `help:"Concurrent probe workers (0 = number of CPUs)" short:"j" default:"0"`
Diff string `help:"Show diff for files whose content differs; bare = internal diff, --diff=tool uses the named tool" default:""`
Modules []string `arg:"" optional:"" name:"modules" help:"Limit scope to these modules (space or comma separated)"`
// contains filtered or unexported fields
}
StatusCmd reports drift between the resolved profile and the live system, plus the apply resume cursor. Read-only; exits 0 even when drift is found.
type VersionCmd ¶
type VersionCmd struct{}
VersionCmd shows version information
func (*VersionCmd) Run ¶
func (v *VersionCmd) Run(version string) error
Run prints the application name and version.