summaryrefslogtreecommitdiff
path: root/internal/askcli/formatter.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-27 11:33:33 +0200
committerPaul Buetow <paul@buetow.org>2026-03-27 11:33:33 +0200
commitf57ccb885d20c48e1dae65b8ad5c46375b9a11a9 (patch)
treea023c5f5af65cfe8f20354c388c683c57437e5d2 /internal/askcli/formatter.go
parent56e9f980e52a53197ace71acdb277ba0e0368916 (diff)
docs: document askcli exports
Diffstat (limited to 'internal/askcli/formatter.go')
-rw-r--r--internal/askcli/formatter.go5
1 files changed, 5 insertions, 0 deletions
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)