Skip to content

Commandline management - #3

Open
Guacimo wants to merge 24 commits into
mainfrom
add-commands
Open

Commandline management#3
Guacimo wants to merge 24 commits into
mainfrom
add-commands

Conversation

@Guacimo

@Guacimo Guacimo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

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:

cargo crateplace add section -n "second_flash" -o 1024K -l 512K -p 4

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

  • ByteUnit has 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.
  • Error printing is now more consistent and hopefully readable.

@jerrysxie
jerrysxie requested review from felipebalbi and jerrysxie and a lite review from Copilot August 4, 2026 17:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 init flow that can derive Memory.toml from memory.x.
  • Refactored ByteUnit into 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.

Comment thread src/main.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/config.rs Outdated
Comment thread src/main.rs Outdated
Comment thread src/init.rs Outdated
Comment thread src/config.rs Outdated
Comment thread src/config.rs Outdated
Comment thread src/config.rs Outdated
Comment thread src/mangling.rs Outdated
@Guacimo
Guacimo marked this pull request as draft August 5, 2026 10:09

@felipebalbi felipebalbi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there's quite a bit of testable functionality without matching tests. Few more comments follow.

Comment thread src/generation.rs
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/mangling.rs Outdated
Comment thread src/config.rs Outdated
Comment thread src/config.rs Outdated
@Guacimo

Guacimo commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

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.

@Guacimo
Guacimo marked this pull request as ready for review August 6, 2026 14:09
@jerrysxie
jerrysxie requested a review from a team as a code owner August 12, 2026 16:45
felipebalbi
felipebalbi previously approved these changes Aug 12, 2026

@jerrysxie jerrysxie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking issues only, but we can really use some unit test for this crate. Created an issue for it: #5

Comment thread src/init.rs Outdated
Comment thread src/init.rs Outdated
Comment thread src/main.rs
Comment thread src/lib.rs Outdated
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
@jerrysxie

jerrysxie commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Pushed an update to address my own review comments.

@felipebalbi please re-review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants