Files
bshell/bshell.runtime/format/format.c
T
wash edfb3e24a3 bshell: re-organise build into three separate components
bshell: the front-end binary
bshell.runtime: contains the parser, compiler, and classes needed to run bshell scripts
bshell.core: contains the builtin commandlets and aliases
2026-05-25 10:33:29 +01:00

29 lines
695 B
C

#include <bshell/format.h>
#include <fx/term/print.h>
#include <fx/type.h>
#include <fx/value-type.h>
static void format_value_fallback(const fx_value *value, fx_stream *dest)
{
fx_printf("[yellow]");
fx_value_to_string(value, dest, NULL);
fx_printf("[reset]\n");
}
enum bshell_status format_value_default(const fx_value *value, fx_stream *dest)
{
if (fx_type_is_value_type(value->v_type)) {
format_value_fallback(value, dest);
return BSHELL_SUCCESS;
}
fx_object *object = NULL;
fx_value_get_object(value, &object);
enum bshell_status status = format_object_table(object, dest);
if (status != BSHELL_SUCCESS) {
format_value_fallback(value, dest);
}
return BSHELL_SUCCESS;
}