Command line parser/validator for deterministic CBOR (dCBOR)
npm install @bcts/dcbor-cli> Disclaimer: This package is under active development and APIs may change.
@bcts/dcbor-cli is a command line tool for parsing, validating, and converting dCBOR (Deterministic CBOR) data.
Features:
- Validates dCBOR inputs
- Receives inputs in hex, binary, or diagnostic notation format
- Outputs in multiple formats: diagnostic notation (compact or annotated), hexadecimal (compact or annotated), or binary
- Compose dCBOR arrays and maps from individual elements
This TypeScript implementation is based on bc-dcbor-cli v0.17.1 (commit).
``bashInstall globally
bun add -g @bcts/dcbor-cli
Usage
$3
Convert CBOR diagnostic notation to hexadecimal (default):
`bash
dcbor '42'
Output: 182a
dcbor '3.14'
Output: fb40091eb851eb851f
dcbor '"Hello"'
Output: 6548656c6c6f
`$3
`bash
Convert hex to diagnostic notation
dcbor --in hex --out diag 6548656c6c6f
Output: "Hello"
Convert with annotations
dcbor --in hex --out diag --annotate 6548656c6c6f
Output: "Hello" / text(5) /
Convert to binary
dcbor --in hex --out bin 6548656c6c6f > output.binRead binary input
dcbor --in bin < input.bin
`$3
`bash
Compose an array
dcbor array 1 2 3
Output: hex for [1, 2, 3]
Compose a map
dcbor map '"key1"' 1 '"key2"' 2
Output: hex for {"key1": 1, "key2": 2}
`Command Line Reference
`
Usage: dcbor [options] [input] [command]Commands:
array Compose a dCBOR array from the provided elements
map Compose a dCBOR map from the provided keys and values
Arguments:
input Input dCBOR (format specified by --in)
Options:
-i, --in Input format: diag, hex, bin (default: diag)
-o, --out Output format: diag, hex, bin, none (default: hex)
-a, --annotate Add annotations to output
-h, --help Display help
-V, --version Display version
``