test: commands now accept stdout/stderr fields.

This commit is contained in:
2026-06-15 17:00:45 -04:00
parent ec96dff055
commit 4600c81401
18 changed files with 157 additions and 160 deletions

View File

@@ -2,7 +2,6 @@ package main
import "core:encoding/json"
import "core:fmt"
import "core:io"
import "core:os"
import "core:path/filepath"
import "core:strings"
@@ -41,8 +40,7 @@ cmd_list :: proc(cmd: ^Command) {
append(&table_rows, row_slice)
}
w := io.to_writer(os.to_writer(os.stdout))
render_table(w, headers, table_rows[:])
render_table(cmd.out, headers, table_rows[:])
} else {
// TODO: Should we instead print full entries here?
entries: [dynamic]ListEntry
@@ -59,10 +57,10 @@ cmd_list :: proc(cmd: ^Command) {
data, marshal_err := json.marshal(entries[:], allocator = context.temp_allocator)
if marshal_err != nil {
fmt.printf("Error marshaling JSON: %v\n", marshal_err)
fmt.wprintf(cmd.err, "Error marshaling JSON: %v\n", marshal_err, flush = false)
return
}
fmt.println(string(data))
fmt.wprintln(cmd.out, string(data), flush = false)
}
}