Repository navigation
feat(cli): make decdn get -o optional with per-target defaults - #2466
Conversation
Without -o, a blob lands at ./<hash>, a bundle in ., and an entry URI at ./<name> (the last segment of its path, without its parent directories). The command names the destination on stderr before the pull starts, except under --json or --dry-run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GBt8wsxcjbQhMTA9JwZAvQ
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GBt8wsxcjbQhMTA9JwZAvQ
There was a problem hiding this comment.
🟢 Approval recommended
The optional--o defaults are fully and correctly wired through every call site, flattening cannot collide, and the behavior is covered by new unit tests and consistent docs/ADR/CHANGELOG updates.
0 open findings
What changed in this PR
This PR makes the -o flag of decdn get optional. When omitted, the destination is derived from the decdn: URI's target: a blob lands at ./<hash>, a whole bundle in ., and a single entry at ./<name> (the entry path's last segment, flattened with no parent directories). The command announces the resolved destination on stderr before pulling (suppressed under --json/--dry-run). This is a client-side CLI ergonomics change in the cli crate; it adds no protocol, on-chain, or economic surface.
Changes:
GetArgs.outputbecomesOption<PathBuf>; a newDestination { root, flatten }resolver (get.rs) computes the per-target default and the user-facing path.fetch::fetchnow takes a resolvedoutput: &Path;bundle_pull::bundle_pulltakes a&Destination, withflattenthreaded ontoEntryFilterso one entry'spathis cut to its file name for live pulls and--dry-runalike.- Docs updated:
GetArgs/module docstrings,CHANGELOG.md, andadr/appendix-bundles.mdgain a "Default destination" bullet; new unit tests cover the defaults, explicit-o, and entry flattening.
| File | Description |
|---|---|
crates/common/src/cli/get.rs |
Makes output an Option<PathBuf> and documents the per-target defaults. |
crates/cli/src/commands/get.rs |
Adds Destination::of/shown, the stderr announcement, and updates the stdout (-o -) guard for the optional flag. |
crates/cli/src/commands/fetch.rs |
fetch takes the resolved output: &Path; doc wording updated. |
crates/cli/src/commands/bundle_pull.rs |
Threads the resolved out/Destination through the pull, adds flatten + flatten_entry. |
crates/cli/src/commands/get/tests.rs |
New tests for default resolution and explicit -o. |
crates/cli/src/commands/bundle_pull/tests.rs |
Updates callers for the new signature; adds a flatten test. |
CHANGELOG.md |
Documents the optional--o behavior. |
adr/appendix-bundles.md |
Adds the "Default destination" bullet. |
Verification notes: all args.output reads on GetArgs are correctly converted to Option accesses; the two remaining args.output reads in fetch.rs belong to BlobFetch (a PathBuf), not GetArgs. The gateway builds BlobFetch directly, so it is unaffected. Flattening only ever applies to entry URIs, which keep exactly one entry, so no filename collision is possible. --dry-run shares the same filter path, so its layout matches live pulls. The ADR edit documents a pure local-UX default and introduces no enforceable/on-chain mechanism.
🧠 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, Solidity Rust / code-coverage/cargo-llvm-cov
View coverage of the 10 most impacted files.
Solidity / code-coverage/forge
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
Without -o, a bundle or entry pull writes into the current directory, which the user did not choose. The engine fetches over a file whose bytes differ from its entry's, so a bare `decdn get decdn:<h>/x/config.json` replaced the user's own ./config.json. A pull without -o now refuses any entry path that holds a file no earlier pull recorded, unless --overwrite; the dry run refuses the same way. The new `decdn_client::bundle::unrecorded_paths` names those paths. The pull's own state paths (.decdn-manifest.json, .decdn-bundles/) are reserved like .decdn-partial/, so a flattened entry cannot land on them. Destination now carries the entry's landing name, taken once from the URI path's last segment, in place of a flatten flag; EntryFilter takes it through a setter that drops it without an entry URI. The stderr line names the absolute destination. Docs, ADR, CHANGELOG and README follow. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Gas snapshotNo gas changes vs base. |
What
decdn getno longer requires-o. Without it, the destination follows the URI target:decdn:<hash>./<hash>decdn:<hash>/.decdn:<hash>/<path>./<name>(last segment of<path>, no parent dirs)When
-ois omitted, the command printsDownloading to <absolute path>on stderr before the pull starts. It does not print it under--jsonor--dry-run.Without
-o, a bundle or entry pull refuses an entry path that already holds a file no earlier pull recorded in.decdn-manifest.json, unless--overwrite. The dry run refuses the same way. This keeps a baredecdn get decdn:<h>/x/config.jsonfrom replacing the user's own./config.json.Reviewer notes
get.rsresolves aDestination { path, entry_name }.entry_nameis the URI path's last segment, set only for an entry URI without-o.fetch::fetchtakes the resolved file path, andbundle_pull::bundle_pulltakes theDestination. Everything that readargs.outputnow reads the resolved path instead.EntryFilter::landing_asrenames the one kept entry toentry_name; a filter with no entry URI drops the name. Live pulls and--dry-runsee the same layout.decdn_client::bundle::unrecorded_paths(public API snapshot updated) backs the refusal. The engine also reserves.decdn-manifest.jsonand.decdn-bundles/like.decdn-partial/, so no entry lands on the pull's own state.-obehaves exactly as before. An entry URI with-o dirstill lands atdir/<path>..decdn-manifest.json,.decdn-bundles/,.decdn-partial/) into the current directory, the same as-o .does today.appendix-bundles.mdgains a "Default destination" bullet.Verification
cargo fmt -- --checkcargo clippy -p decdn-cli -p decdn-common --all-targets: cleancargo test -p decdn-cli --lib: 655 passed, including new tests for the defaults, the explicit-o, and entry flattening (cargo nextestis not installed in this environment)cargo test -p decdn-cli --test get_node_dir_guardCARGO_BUILD_WARNINGS=deny cargo doc -p decdn-cli -p decdn-common --no-deps --document-private-itemsCHANGELOG.mdentry addedadr/updated🤖 Generated with Claude Code
https://claude.ai/code/session_01GBt8wsxcjbQhMTA9JwZAvQ
Generated by Claude Code