Skip to main content

Token-minimal field projection over JSON, YAML, TOML and NDJSON. The anti-jq for agents.

Project description

dotpick

CI crates.io clispec

Token-minimal field projection over JSON, YAML, TOML and NDJSON. Select fields by dotpath and emit the smallest valid slice. The anti-jq for agents and scripts: pure projection and format conversion, with no expression language to get wrong.

Why

jq and yq dump whole payloads, speak cryptic error messages, and jq cannot even read YAML or TOML. When you only need three fields out of a 50 KB response, you pay for the other 49 KB. dotpick takes a simple list of dotpaths and returns just those fields, in the format you ask for.

# 50 KB of pod JSON in, one name per line out
kubectl get pods -o json | dotpick '.items[].metadata.name' -o raw

Install

cargo install dotpick

Quickstart

# Smallest sub-document of two fields (structure preserved)
echo '{"metadata":{"name":"web","ns":"prod"},"spec":{"replicas":3}}' \
  | dotpick '.metadata.name,.spec.replicas'
# => {"metadata":{"name":"web"},"spec":{"replicas":3}}

# Just the value, unquoted
dotpick .spec.replicas deploy.yaml -o raw
# => 3

# Flatten to leaf names
dotpick '.metadata.name,.spec.replicas' deploy.yaml --flat
# => {"name":"web","replicas":3}

# Stream array elements as NDJSON
cat pods.json | dotpick '.items[]' -o ndjson
# => {"name":"a"}
#    {"name":"b"}

# Convert formats with the root path
dotpick . config.toml -o yaml

dotpick <paths> [file] is shorthand for dotpick project <paths> [file].

Dotpath grammar

Syntax Meaning
.key object key (bareword [A-Za-z0-9_-]+)
["any.key"] quoted key, for keys with dots, spaces or brackets
[0] array index (non-negative)
[] iterate every element of an array
. the whole document (useful for format conversion)
.a.b[0].c[].d chain segments freely
.a.b,.c[].d comma-separate multiple paths

Output shapes

  • structured (default): the smallest sub-document that keeps the original nesting.
  • --flat: an object keyed by each path's final name.
  • -o raw: bare scalar values, one per line (great for shell capture).
  • -o ndjson: one compact JSON value per selected match; [] controls granularity (.items[] streams elements, .items[].name streams names).

Object keys are emitted in sorted order for stable, diff-friendly output.

Formats

Input format is auto-detected (or taken from the file extension, or forced with --from json|yaml|toml|ndjson). Output is selected with -o/--output (auto, json, yaml, toml, ndjson, raw); auto is JSON, or NDJSON when the input is NDJSON. --to is an alias for --output. Use --pretty for indented JSON.

Missing fields

By default a missing path is an error with a "nearest existing key" hint:

echo '{"spec":{"replic":3}}' | dotpick .spec.replicas
# stderr: {"error":{"kind":"path_not_found","message":"path .spec.replicas not found; nearest existing: replic", ...}}

Pass --allow-missing to skip absent paths instead.

Exit codes

Code Meaning
0 success
1 no match (a selected path is absent, or a wrong-typed segment)
2 parse, serialize, or IO failure
3 usage error (bad arguments, bad dotpath, name collision, raw on non-scalar)

For agents (clispec)

dotpick follows The CLI Spec: data on stdout, structured error envelopes on the last line of stderr, and a schema subcommand whose output validates against clispec.dev/schema/v0.2.json (checked by the test suite). Every command is marked read-only (mutating: false).

dotpick schema   # machine-readable contract: commands, args, error kinds, exit codes

dotpick is a stateless filter, so the list-oriented principles (pagination, resource conflicts) do not apply; its paths argument is itself the field selector.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dotpick-0.1.0.tar.gz (33.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

dotpick-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (727.4 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

dotpick-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (673.6 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

dotpick-0.1.0-py3-none-macosx_11_0_arm64.whl (657.2 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

dotpick-0.1.0-py3-none-macosx_10_12_x86_64.whl (707.5 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file dotpick-0.1.0.tar.gz.

File metadata

  • Download URL: dotpick-0.1.0.tar.gz
  • Upload date:
  • Size: 33.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dotpick-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1d4a15327c1db5f57a9ebd3c4b2a9963d8569c46d9921eba31a0d675517f7389
MD5 dd8cf756d407c06fd27258d0f38e2436
BLAKE2b-256 090e922f79b084e6f2b104f6dc4da48e12f3b696cea23aea78641e462df54426

See more details on using hashes here.

File details

Details for the file dotpick-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: dotpick-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 727.4 kB
  • Tags: Python 3, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dotpick-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 310d919321dfad516862804492c1faac4261d54f7834c318e74b28a2f7f79d7b
MD5 ac06ecb5c3a13cadcebaba19af91a20e
BLAKE2b-256 d2145a5edc262754c515df8005c0ca52297998013ca4f6d9f37246c625da20ef

See more details on using hashes here.

File details

Details for the file dotpick-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: dotpick-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 673.6 kB
  • Tags: Python 3, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dotpick-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d0c62846c17603ed7702d1914ea67c1a2b77f7e5c63b3c9476c3f364f13aa337
MD5 f18b844026906855f7d47c634925a6d7
BLAKE2b-256 2fa3fc15a4f8208408db6634115a30f524f34229710e050593fa5a837b731066

See more details on using hashes here.

File details

Details for the file dotpick-0.1.0-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: dotpick-0.1.0-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 657.2 kB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dotpick-0.1.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2a703b6314db0880c7dd842c1d94bead9760d69ed4c8160edc39737613daaef3
MD5 d4adba5efa6a22070fa754ac7fdc1636
BLAKE2b-256 5f4c65f3864efe58a2bac6a2f9f4f2a72b41df372e43c5c5d973d13a9062cc6e

See more details on using hashes here.

File details

Details for the file dotpick-0.1.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: dotpick-0.1.0-py3-none-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 707.5 kB
  • Tags: Python 3, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dotpick-0.1.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1228ac82afe78989e6912de7d015fd738029fbbd33c6197f67c0edb6b9e1f415
MD5 e5fe51fe84e518dfa11f25d6b2f5c70b
BLAKE2b-256 bbc9f15ab296ecbc62f5ff2df46978ac31a2818c08da9ea8392a7654a02f4017

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page