Commandline management - #3
Conversation
Configuration can now be edited through the crateplace commandline application.
There was a problem hiding this comment.
🟡 Not ready to approve
Introduced issues include incorrect config serialization logic and multiple places where write operations are mapped as read errors, leading to incorrect behavior and misleading diagnostics.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR adds richer command-line management to crateplace (init + config editing commands) and refactors config parsing/formatting (notably ByteUnit) while aiming to make error output more consistent across the tool.
Changes:
- Added CLI subcommands to add/remove sections/crates/symbols, set RAM, and validate config; implemented a new
initflow that can deriveMemory.tomlfrommemory.x. - Refactored
ByteUnitinto a structured type with formatting metadata and added TOML integer deserialization support. - Normalized many error messages and improved terminal-styled error reporting.
File summaries
| File | Description |
|---|---|
| src/validation.rs | Error message normalization + IO error mapping rename usage. |
| src/mangling.rs | Error message normalization for mangling detection failures. |
| src/main.rs | Adds new CLI commands and in-binary init implementation. |
| src/lib.rs | Exposes constants/lookup, adds config mutation APIs, improves error printing. |
| src/init.rs | Replaces old init with memory.x parsing + build.rs/Cargo.toml patch helpers. |
| src/generation.rs | Small refactor + embeds “Generated by crateplace” marker in output. |
| src/file_error.rs | Renames IO-to-file-error mapping helpers and flips messages to read/write. |
| src/deps.rs | Error message normalization. |
| src/config.rs | ByteUnit redesign + adds TOML-based config modification methods. |
| src/assignment.rs | Minor iteration cleanup + error message normalization. |
| Cargo.toml | Adds new dependencies (syn, proc-macro2, toml_edit) for init/build.rs editing. |
| Cargo.lock | Lockfile updates for new deps and dependency bumps. |
Review details
Suppressed comments (8)
src/main.rs:381
- IgnoreList::to_file writes to disk; using into_in_result will incorrectly report this as a read failure if it errors.
crateplace::validation::IgnoreList::default()
.to_file(&ignorelist_path)
.into_in_result(&ignorelist_path)?;
src/lib.rs:477
- IgnoreList::to_file writes to disk; using into_in_result will misclassify write errors as read errors.
let new_list = IgnoreList::new(&patterns)?;
new_list
.to_file(&ignore_list_path)
.into_in_result(&ignore_list_path)?;
src/config.rs:440
- fs::write is a write operation; mapping it with into_in_result will report "failed to read" on write failures. Use into_out_result here.
fs::write(config_path, toml.to_string().into_bytes()).into_in_result(config_path)?;
src/config.rs:491
- fs::write is a write operation; mapping it with into_in_result will report "failed to read" on write failures. Use into_out_result here.
fs::write(config_path, toml.to_string().into_bytes()).into_in_result(config_path)?;
src/config.rs:521
- fs::write is a write operation; mapping it with into_in_result will report "failed to read" on write failures. Use into_out_result here.
fs::write(config_path, toml.to_string().into_bytes()).into_in_result(config_path)?;
src/config.rs:584
- fs::write is a write operation; mapping it with into_in_result will report "failed to read" on write failures. Use into_out_result here.
fs::write(config_path, toml.to_string().into_bytes()).into_in_result(config_path)?;
src/config.rs:615
- fs::write is a write operation; mapping it with into_in_result will report "failed to read" on write failures. Use into_out_result here.
fs::write(config_path, toml.to_string().into_bytes()).into_in_result(config_path)?;
src/config.rs:634
- fs::write is a write operation; mapping it with into_in_result will report "failed to read" on write failures. Use into_out_result here.
fs::write(config_path, toml.to_string().into_bytes()).into_in_result(config_path)?;
- Files reviewed: 11/12 changed files
- Comments generated: 9
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
felipebalbi
left a comment
There was a problem hiding this comment.
It looks like there's quite a bit of testable functionality without matching tests. Few more comments follow.
Yes, I think I underestimated the complexity of "crateplace" in general and probably should have begun writing formal tests earlier. We can definitely discuss a testing strategy. I don't think I should start adding testing to this pull request specifically though. |
The merge from main added the cargo-vet store, but this branch bumps and adds dependencies (toml_edit, syn 3.0.3, proc-macro2, and others) that were neither audited nor exempted, and machete flagged proc-macro2 as unused. Refresh the imported audits and regenerate exemptions so the locked vet check passes, and ignore proc-macro2 in cargo-machete since it is declared only to enable syn's span-locations feature. Assisted-by: GitHub Copilot:Claude Opus 4.8 [cargo-vet cargo-machete]
Back up Cargo.toml before writing the updated manifest. Correct user-facing diagnostics and error variant typos. Assisted-by: GitHub Copilot
|
Pushed an update to address my own review comments. @felipebalbi please re-review. |
Commandline management
Commands have added to make using crateplace easier.
The add command allows adding and removing sections, crates, or symbols to "Memory.toml". For instance:
The help shows how to use the specific commands.
The init command will attempt to initialize the project to a working crateplace state.
This includes adding crateplace as a build dependency, adding the necessary code to the buildscript and placing default configuration files. "Memory.toml" is generated based on the content of "memory.x" if present. The parser is limited so not all "memory.x" files will be consumable by "crateplace init" in that case manual configuration is necessary.
Additional improvements
ByteUnithas been upgraded and now supports parsing from integer fields in toml. The format names are now more expicit and it is now a struct separating the formatting enum from the byte value.