How-to guides
Automate Moji with JSON
Use structured output and exit codes in scripts and pipelines.
Add --json whenever another program will parse the output:
moji "Inter" --format otf --jsonSearch output is an array of result objects. Each object includes:
name,filename,format, andweightsize_byteswhen knownsourceand the directurltrustedand the best-effortlicensehint- the calculated
score
Select a field with jq
moji "Inter" --format otf --json |
jq -r '.[].url'Preview an automated download
moji get "Inter bold" --dry-run --json |
jq '.[0] | {filename, source, license}'Check exit status
if moji get "Inter bold" --dry-run --json > selection.json; then
jq '.[0]' selection.json
else
echo "Moji could not select a font" >&2
exit 1
fiMoji writes primary data to standard output and diagnostics to standard error.
Exit 0 means success, 2 means invalid command usage, and 1 means an
operational failure.