add colour object

This commit is contained in:
2023-06-19 23:58:34 +01:00
parent 3f048ce645
commit 3bf48079d5
9 changed files with 370 additions and 42 deletions

View File

@@ -74,9 +74,11 @@ func anyToArgon(x any, quote bool, simplify bool, depth int, indent int, colored
if colored {
output = append(output, "\x1b[0m")
}
case ArObject:
case anymap:
if len(x) == 0 {
return "<>"
return "{}"
}
keys := make([]any, len(x))
sort.Slice(keys, func(i, j int) bool {
@@ -107,7 +109,7 @@ func anyToArgon(x any, quote bool, simplify bool, depth int, indent int, colored
}
output = append(output, keyval+": "+anyToArgon(x[key], true, true, depth-1, indent+1, colored, plain))
}
return "<" + maybenewline + (strings.Repeat(" ", (indent+1)*plain)) + strings.Join(output, ","+maybenewline+(strings.Repeat(" ", (indent+1)*plain))) + maybenewline + (strings.Repeat(" ", indent*plain)) + ">"
return "{" + maybenewline + (strings.Repeat(" ", (indent+1)*plain)) + strings.Join(output, ","+maybenewline+(strings.Repeat(" ", (indent+1)*plain))) + maybenewline + (strings.Repeat(" ", indent*plain)) + "}"
case []any:
singleline := len(x) <= 3
output := []string{}