Add colour package for JSON and YAML highlighting #4
Reference in New Issue
Block a user
Delete Branch "benvin/colour"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
CLI tools such as vctx print vault JSON/YAML to terminals with no highlighting, and each would otherwise grow its own colouriser.
colour.JSONwith jq's default palette and jq 1.8.1JQ_COLORSparsingcolour.YAMLwith yq's palette and number rules for block maps/seqs, single- and multi-line scalars,|/>blocks, flow collections, anchors and commentscolour.Enabled(Auto/Always/Never) honouring TTY,NO_COLORandTERM=dumbblock = indentuses the line indent, so a block scalar opened on a dash line (- cert: |) swallows the item's sibling keys as string content; realvault kv get -format=yamlwith a list of maps rendersttl: 768hafter the PEM all green → set the threshold to the column of the key / innermost-and add a- a: |\n x\n b: 1\ncase to TestYAMLEdgesfolded: onto next line"gets key colour → track an open multi-line quoted scalar or leave continuation lines plain1e3is green in yq,0o17/.inf/012uncoloured,1_000magenta → drop the claim of matching yq for these or align the regex…:4;31xsets4;31; this rejects the whole variable → validate only the digits/;prefix of the 8th fieldTERM=dumb→ drop "follows jq" or say TERM=dumb is an addition'?'rejects every key starting with?, but yaml.v2/v3 emit plain keys like?q:unquoted (indicator only when followed by space/EOL); the line is painted as an open plain scalar, so the key and its whole nested block (?q:\n nested: 1\n pem: |) come out green where yq colours key/number/string → treat?as an indicator only when followed by a space or end of line, as for-, and add a case to TestYAMLEdgesNo findings.