Repository navigation
feat(cli): add decdn get <decdn: URI> over fetch and bundle pull - #2460
Conversation
…2449) `get` parses a `decdn:` URI and routes it to the existing commands: a blob URI runs `decdn fetch`, `decdn:<hash>/` runs `decdn bundle pull`, and `decdn:<hash>/<path>` runs the bundle pull with one escaped `--include` glob that matches exactly that path. The URI's `ns` is the namespace hint. Bundle-only flags are rejected on a blob URI, entry filters on an entry URI, and `-o -` on anything but a blob URI. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The change is an additive, well-tested CLI routing layer whose integration points (struct fields, function signatures, exports, hash format, and flag rules) all verify correctly, with no protocol, on-chain, or storage impact.
0 open findings
What changed in this PR
This PR adds a new decdn get <decdn: URI> command as a thin routing layer over the existing decdn fetch and decdn bundle pull commands, implementing the first step of #2449. It parses a decdn: URI (via the decdn_client::uri::DecdnUri parser from #2455) and dispatches to the blob fetch (decdn:<hash>), a whole-bundle pull (decdn:<hash>/), or a single-entry pull (decdn:<hash>/<path>), carrying the optional ?ns= namespace hint and the shared retrieval flags. The underlying fetch and bundle pull commands are left intact for a follow-up cleanup PR.
Changes:
- Adds
GetArgs(decdn-common) and thegetcommand (decdn-cli) that parses the URI, enforces per-target flag rules (bundle flags rejected on blob URIs, entry filters rejected on entry URIs,-o -only for blobs), and builds aFetchArgsorBundlePullArgs. - Extracts the bundle-pull defaults into
DEFAULT_JOBS/DEFAULT_MAX_LANE_STREAMSconstants so bothbundle pullandgetshare one source;getmakes--jobs/--max-lane-streamsOptionto detect whether they were supplied on a blob URI. - Escapes entry paths with
globset::escape(plus Unix backslash handling) so a filename with glob metacharacters matches exactly one entry; adds 10 unit tests and updates theCLAUDE.mdcommand list.
| File | Description |
|---|---|
crates/common/src/cli/get.rs |
New GetArgs struct: the URI, destination, bundle/entry flags, and flattened ClientFetchArgs. |
crates/common/src/cli/mod.rs |
Registers the get module, re-exports GetArgs, and adds the Command::Get variant with help text. |
crates/common/src/cli/bundle.rs |
Extracts DEFAULT_JOBS/DEFAULT_MAX_LANE_STREAMS constants and uses them as the bundle pull defaults. |
crates/cli/src/commands/get.rs |
New routing logic: parse the URI, enforce flag rules, and build FetchArgs/BundlePullArgs, including literal_glob escaping. |
crates/cli/src/commands/get/tests.rs |
Unit tests for every URI kind, namespace pass-through, shared-flag carry-over, flag rules, and glob metacharacter paths. |
crates/cli/src/commands/mod.rs |
Registers the get command module. |
crates/cli/src/main.rs |
Dispatches Command::Get to commands::get::get. |
CLAUDE.md |
Adds get to the decdn binary command list in the Status note. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit da76e97 in the Show a line coverage summary of the most impacted files.
Updated |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Part of #2449. This is the first step:
decdn getis a thin routing layer over the existing commands. A follow-up PR deletesdecdn fetchanddecdn bundle pulland moves their callers toget.What it does
decdn get <URI> -o <OUT>parses the URI withdecdn_client::uri::DecdnUri(#2455) and builds the arguments of an existing command:decdn:<hash>decdn fetch(-ois a file, or-for stdout)decdn:<hash>/decdn bundle pullover every entrydecdn:<hash>/<path>decdn bundle pullwith one--includeglob that matches exactly<path>?ns=NNgetflattens the sharedClientFetchArgs, so the discovery, chain, pool and capability flags work as they do today.globset::escape(plus\on Unix, where it is the glob escape), so a filename with*,?,[,],{,}pulls exactly that entry.--include,--exclude,--select,--jobs,--max-lane-streams,--overwrite,--dry-run,--json) are an error on a blob URI.--include,--excludeand--selectare an error on an entry URI.-o -is accepted only for a blob URI.--jobsand--max-lane-streamsareOptionongetso a blob URI can tell they were given. Their defaults move toDEFAULT_JOBS/DEFAULT_MAX_LANE_STREAMSindecdn_common::cli::bundle, whichbundle pullalso uses.ADR
adr/appendix-bundles.mdgains adecdn:URIs section: the grammar, the hash, path andnsrules, and why the URI has no//and marks a bundle with a trailing/.Left for the cleanup PR
fetch,bundle pull,FetchArgs,BundlePullArgsand thebundlegroup; move the e2e tests, CLI tests and docs toget. That includes the ADRs that name the old commands: 012, 039,appendix-bundles.mdandappendix-binaries.md./hint whendecdn:<hash>/names a non-manifest blob.Tests
cargo nextest run -p decdn-cli -p decdn-common: 1230 passed, including 10 newcommands::get::tests(routing for each URI kind, namespace pass-through, shared-flag carry-over, every flag rule, glob metacharacter paths).cargo clippy --workspace --all-targets --all-features,cargo fmt --checkandcargo docare clean.🤖 Generated with Claude Code