Documentation
¶
Index ¶
- Variables
- func Cancelled() error
- func ColorEnabled() bool
- func ConfirmDangerousAction(prompt, expected string, force ...bool) bool
- func ConfirmOverwrite(path string) bool
- func Error(msg string, err error, hints ...string) error
- func ErrorWithHint(msg string, err error, hint string) error
- func Info(msg string)
- func InitOutput(jsonMode, noColor, quiet bool)
- func IsInteractive() bool
- func IsQuiet() bool
- func JSONData(v any)
- func JSONMessage(level string, msg string)
- func MapAPIError(detail *APIErrorDetail) error
- func PadRight(s string, width int) string
- func PlainTimestamp() string
- func PrintEnvSummary(env map[string]string)
- func PrintServiceRoleDetail(role *config.ServiceRole)
- func PrintServiceRolePermissions(perm *config.ServiceRolePermsResponse, repoPrincipal string)
- func PrintServiceRoleSecret(keyPair *config.ServiceRoleKeyPair)
- func PromptWithDefault(label, defaultVal string) string
- func RenderBanner() string
- func RenderDiff(diff cryptoutils.DiffingResult, oldMap, newMap map[string]string, ...)
- func RunActionWithSpinner(title string, action func() error) error
- func RunAuditTable(logs []config.AuditEntry, total int) error
- func RunEnvPicker(projectName string) (string, error)
- func RunForm(fields []FormField, prefills []string) ([]string, error)
- func RunPicker(title string, items []string) (string, error)
- func RunPickerWithDefault(title string, items []string, defaultItem string) (string, error)
- func RunProjectsTable(projects []config.Project) error
- func RunServiceRolesTable(roles []config.ServiceRole) error
- func SetNoTable(v bool)
- func Spacer()
- func StripANSI(s string) string
- func Success(msg string)
- func Truncate(s string, max int) string
- func ValidateEmail(s string) error
- func ValidateFileExists(s string) error
- func ValidateProjectName(s string) error
- func VisibleLen(s string) int
- func Warn(msg string)
- type APIErrorDetail
- type FormField
- type OutputMode
- type TermLevel
Constants ¶
This section is empty.
Variables ¶
var ( // Colors ColorSuccess = lipgloss.Color("2") ColorError = lipgloss.Color("1") ColorWarn = lipgloss.Color("3") ColorInfo = lipgloss.Color("4") ColorMuted = lipgloss.Color("8") ColorPrimary = lipgloss.Color("63") // Matches standard EnvCrypt color // Base Styles StyleSuccess = lipgloss.NewStyle().Foreground(ColorSuccess) StyleError = lipgloss.NewStyle().Foreground(ColorError) StyleWarn = lipgloss.NewStyle().Foreground(ColorWarn) StyleInfo = lipgloss.NewStyle().Foreground(ColorInfo) StyleMuted = lipgloss.NewStyle().Foreground(ColorMuted) StylePrimary = lipgloss.NewStyle().Foreground(ColorPrimary) // Icons IconCheck = StyleSuccess.Render("[✓]") IconCross = StyleError.Render("[x]") IconWarn = StyleWarn.Render("[!]") IconInfo = StyleInfo.Render(">") // Plain-mode icons (no ANSI) PlainIconCheck = "[✓]" PlainIconCross = "[x]" PlainIconWarn = "[!]" PlainIconInfo = ">" // Structural Styles HeaderStyle = lipgloss.NewStyle().Foreground(ColorMuted).Bold(true) BoxStyleWarn = lipgloss.NewStyle(). Border(lipgloss.RoundedBorder()). BorderForeground(ColorWarn). Padding(1). MarginTop(1) BoxStylePrimary = lipgloss.NewStyle(). Border(lipgloss.RoundedBorder()). BorderForeground(ColorPrimary). Padding(1). MarginTop(1) // Centralised navigation hint strings )
var ErrCancelled = errors.New("operation cancelled")
ErrCancelled is returned when the user aborts an operation.
Functions ¶
func Cancelled ¶ added in v1.4.0
func Cancelled() error
Cancelled prints a standardised cancellation message and returns ErrCancelled.
func ColorEnabled ¶ added in v1.4.0
func ColorEnabled() bool
ColorEnabled returns whether ANSI color output is allowed.
func ConfirmDangerousAction ¶
ConfirmDangerousAction prompts the user for confirmation. If force is true, the confirmation is skipped.
func ConfirmOverwrite ¶
func ErrorWithHint ¶ added in v1.4.0
ErrorWithHint renders an error with an actionable hint.
func InitOutput ¶ added in v1.4.0
func InitOutput(jsonMode, noColor, quiet bool)
InitOutput configures the global output mode. Call once from root PersistentPreRun.
func IsInteractive ¶ added in v1.1.1
func IsInteractive() bool
IsInteractive returns true when the CLI should use full interactive TUI. Retained for backward compatibility — delegates to the output mode system.
func JSONData ¶ added in v1.4.0
func JSONData(v any)
JSONData emits arbitrary structured data as JSON to stdout.
func JSONMessage ¶ added in v1.4.0
JSONMessage emits a single structured JSON object to stdout.
func MapAPIError ¶ added in v1.4.0
func MapAPIError(detail *APIErrorDetail) error
MapAPIError converts an APIErrorDetail into a user-friendly error with hint.
func PlainTimestamp ¶ added in v1.4.0
func PlainTimestamp() string
PlainTimestamp returns a bracketed timestamp for plain mode log lines.
func PrintEnvSummary ¶
func PrintServiceRoleDetail ¶
func PrintServiceRoleDetail(role *config.ServiceRole)
func PrintServiceRolePermissions ¶
func PrintServiceRolePermissions(perm *config.ServiceRolePermsResponse, repoPrincipal string)
func PrintServiceRoleSecret ¶
func PrintServiceRoleSecret(keyPair *config.ServiceRoleKeyPair)
func PromptWithDefault ¶
func RenderBanner ¶ added in v1.4.0
func RenderBanner() string
RenderBanner returns a high-fidelity ASCII/styled banner for the CLI.
func RenderDiff ¶
func RenderDiff(diff cryptoutils.DiffingResult, oldMap, newMap map[string]string, showSecrets bool)
func RunActionWithSpinner ¶
RunActionWithSpinner executes an action with a spinner in interactive mode, a static progress line in plain mode, or silently in JSON mode.
func RunAuditTable ¶ added in v1.5.0
func RunAuditTable(logs []config.AuditEntry, total int) error
func RunEnvPicker ¶
func RunPickerWithDefault ¶ added in v1.7.0
func RunProjectsTable ¶
func RunServiceRolesTable ¶
func RunServiceRolesTable(roles []config.ServiceRole) error
func SetNoTable ¶ added in v1.4.0
func SetNoTable(v bool)
func Success ¶
func Success(msg string)
Success prints a success message, dispatched by output mode.
func ValidateEmail ¶ added in v1.4.0
ValidateEmail checks for a valid email format.
func ValidateFileExists ¶ added in v1.4.0
ValidateFileExists checks that a file exists at the given path.
func ValidateProjectName ¶ added in v1.4.0
ValidateProjectName checks that a project name follows naming rules.
func VisibleLen ¶
Types ¶
type APIErrorDetail ¶ added in v1.4.0
type APIErrorDetail struct {
Code string `json:"code"`
Message string `json:"message"`
Hint string `json:"hint"`
}
APIErrorDetail represents the structured error returned by the server.
type FormField ¶
type FormField struct {
Label string
Secret bool
Required bool
Validate func(string) error // optional validation function
}
FormField defines a single input field in a form.
type OutputMode ¶ added in v1.4.0
type OutputMode int
OutputMode determines how the CLI renders output.
const ( ModeInteractive OutputMode = iota ModePlain ModeJSON )