Documentation
¶
Index ¶
- func FormatCommandMessage(verb string, packNames []string) string
- func FormatSymlinkForDisplay(path string, homeDir string, maxLen int) string
- func GetHandlerAdditionalInfo(handlerName string) string
- func GetHandlerSymbol(handlerName string) string
- func TruncateLeft(s string, maxLen int) string
- type CommandMetadata
- type CommandResult
- type DisplayFile
- type DisplayPack
- type DisplayResult
- type GenConfigResult
- type PackCommandResult
- type TextRenderer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatCommandMessage ¶
FormatCommandMessage generates a standard message for command results. It handles pluralization and pack name listing appropriately. Returns empty string if there are no packs (message will be omitted).
Examples:
- FormatCommandMessage("linked", []string{"vim", "git"}) -> "The packs vim and git have been linked."
- FormatCommandMessage("linked", []string{"vim"}) -> "The pack vim has been linked."
- FormatCommandMessage("linked", []string{}) -> ""
func FormatSymlinkForDisplay ¶
FormatSymlinkForDisplay formats a symlink path for display It replaces $HOME with ~ and truncates from the left if needed
func GetHandlerAdditionalInfo ¶
GetHandlerAdditionalInfo returns a short description for the Handler type
func GetHandlerSymbol ¶
GetHandlerSymbol returns the Unicode symbol for a given Handler
func TruncateLeft ¶
TruncateLeft truncates a string from the left side to fit within maxLen characters If the string is longer than maxLen, it returns "..." + the last (maxLen-3) characters
Types ¶
type CommandMetadata ¶
type CommandMetadata struct {
// For 'on' command
TotalDeployed int `json:"totalDeployed,omitempty"`
NoProvision bool `json:"noProvision,omitempty"`
ProvisionRerun bool `json:"provisionRerun,omitempty"`
// For 'off' command
TotalCleared int `json:"totalCleared,omitempty"`
HandlersRun []string `json:"handlersRun,omitempty"`
// For 'adopt' command
FilesAdopted int `json:"filesAdopted,omitempty"`
AdoptedPaths []string `json:"adoptedPaths,omitempty"`
// For 'fill' command
FilesCreated int `json:"filesCreated,omitempty"`
CreatedPaths []string `json:"createdPaths,omitempty"`
// For 'add-ignore' command
IgnoreCreated bool `json:"ignoreCreated,omitempty"`
AlreadyExisted bool `json:"alreadyExisted,omitempty"`
}
CommandMetadata contains command-specific information
type CommandResult ¶
type CommandResult struct {
Message string `json:"message,omitempty"` // Optional message like "The packs vim and git have been linked."
Result *DisplayResult `json:"result"` // The pack status display
}
CommandResult wraps a DisplayResult with an optional message for unified output. This is used by all commands that alter pack state (link, unlink, provision, on, off, etc.) to provide a consistent output format:
<Optional Message> <pack status representation>
type DisplayFile ¶
type DisplayFile struct {
Handler string `json:"handler"`
Path string `json:"path"`
Status string `json:"status"` // File-level: "success", "error", "queue", "config", "ignored"
Message string `json:"message"`
IsOverride bool `json:"isOverride"` // File handler was overridden in .dodot.toml
LastExecuted *time.Time `json:"lastExecuted"` // When operation was last executed
HandlerSymbol string `json:"handlerSymbol"` // Unicode symbol for the handler
AdditionalInfo string `json:"additionalInfo"` // Additional context (e.g., symlink target, shell type)
}
DisplayFile represents a single file within a pack for display.
type DisplayPack ¶
type DisplayPack struct {
Name string `json:"name"`
Status string `json:"status"` // Aggregated: "alert", "success", "queue"
Files []DisplayFile `json:"files"`
HasConfig bool `json:"hasConfig"` // Pack has .dodot.toml
IsIgnored bool `json:"isIgnored"` // Pack has .dodotignore
}
DisplayPack represents a single pack for display.
func (*DisplayPack) GetPackStatus ¶
func (dp *DisplayPack) GetPackStatus() string
GetPackStatus determines the pack-level status based on its files. Following the aggregation rules from the design: - If ANY file has ERROR status → Pack status is "alert" - If ANY file has WARNING status (but no errors) → Pack status is "partial" - If ALL files have SUCCESS status → Pack status is "success" - Empty pack or mixed states → Pack status is "queue"
type DisplayResult ¶
type DisplayResult struct {
Command string `json:"command"` // "status", "link", "provision"
Packs []DisplayPack `json:"packs"`
DryRun bool `json:"dryRun"` // For deploy/install commands
Timestamp time.Time `json:"timestamp"`
}
DisplayResult is the top-level structure for commands that produce rich output. This replaces the old PackStatusResult and is used by status, deploy, and install commands.
type GenConfigResult ¶
type GenConfigResult struct {
ConfigContent string `json:"configContent"`
FilesWritten []string `json:"filesWritten"`
}
GenConfigResult holds the result of the 'gen-config' command. This is kept separate as it doesn't follow the pack command pattern.
type PackCommandResult ¶
type PackCommandResult struct {
// Command that was executed
Command string `json:"command"` // "up", "down", "status", "adopt", "fill", "add-ignore"
// Packs affected by the command with their current status
Packs []DisplayPack `json:"packs"`
// Optional message for the command (e.g., "The pack vim has been turned on.")
Message string `json:"message,omitempty"`
// Metadata specific to the command
Metadata CommandMetadata `json:"metadata,omitempty"`
// Whether this was a dry run
DryRun bool `json:"dryRun"`
// When the command was executed
Timestamp time.Time `json:"timestamp"`
}
PackCommandResult is the unified result type for all pack-related commands. It combines pack status display with command-specific metadata.
type TextRenderer ¶
type TextRenderer struct {
// contains filtered or unexported fields
}
TextRenderer provides minimal text output for dodot commands
func NewTextRenderer ¶
func NewTextRenderer(w io.Writer) *TextRenderer
NewTextRenderer creates a new text renderer
func (*TextRenderer) Render ¶
func (r *TextRenderer) Render(result *DisplayResult) error
Render outputs the DisplayResult in a simple text format