From f57ccb885d20c48e1dae65b8ad5c46375b9a11a9 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 27 Mar 2026 11:33:33 +0200 Subject: docs: document askcli exports --- internal/askcli/formatter.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'internal/askcli/formatter.go') diff --git a/internal/askcli/formatter.go b/internal/askcli/formatter.go index 743637b..2327a94 100644 --- a/internal/askcli/formatter.go +++ b/internal/askcli/formatter.go @@ -9,10 +9,12 @@ import ( "codeberg.org/snonux/hexai/internal/termprint" ) +// FormatTaskList renders a table of tasks using the terminal's width when possible. func FormatTaskList(tasks []TaskExport, aliases map[string]string) string { return FormatTaskListForWidth(tasks, aliases, 0) } +// FormatTaskListForWidth renders a table of tasks constrained to the provided terminal width. func FormatTaskListForWidth(tasks []TaskExport, aliases map[string]string, terminalWidth int) string { widths := taskListWidthsFor(tasks, aliases, terminalWidth) var b strings.Builder @@ -133,6 +135,7 @@ func detectTaskListTerminalWidth(w io.Writer) int { return termprint.DetectTerminalWidth(w) } +// FormatTaskInfo builds a human-readable block describing a single task. func FormatTaskInfo(t TaskExport, alias string, dependencyAliases map[string]string) string { var b strings.Builder fmt.Fprintf(&b, "ID: %s\n", alias) @@ -160,10 +163,12 @@ func FormatTaskInfo(t TaskExport, alias string, dependencyAliases map[string]str return b.String() } +// FormatSuccess returns the success string written to stdout after a task command runs. func FormatSuccess(alias string) string { return fmt.Sprintf("ok %s\n", alias) } +// FormatError formats error output using the optional task identifier when available. func FormatError(err error, taskID string) string { if taskID != "" { return fmt.Sprintf("error %s: %v\n", taskID, err) -- cgit v1.2.3