Skip to content

landing a better organized cli structure#6

Merged
Bechma merged 1 commit intocyberfabric:mainfrom
Bechma:structure-cli
Mar 2, 2026
Merged

landing a better organized cli structure#6
Bechma merged 1 commit intocyberfabric:mainfrom
Bechma:structure-cli

Conversation

@Bechma
Copy link
Copy Markdown
Collaborator

@Bechma Bechma commented Mar 2, 2026

Summary by CodeRabbit

  • New Features

    • Added a top-level Mod command with Init and Add subcommands for managing modules
    • Added a new Tools command to the CLI
  • Bug Fixes

    • Fixed subfolder handling during local-path initialization
    • Ignore SDK-target crates when auto-detecting module names
  • Improvements

    • CLI command structure simplified (legacy Setup/Config removed)
    • Registry messages changed from warnings to informational status

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 2, 2026

📝 Walkthrough

Walkthrough

Consolidates CLI argument types (renames CommonArgs → BuildRunArgs and removes flattened common_args fields), replaces the Setup command hierarchy with Mod and Tools variants, adds a new mod subcommand (Init, Add), updates build/run to use BuildRunArgs, and filters out "*sdk" library targets in module parsing.

Changes

Cohort / File(s) Summary
CLI entry and commands
crates/cli/src/main.rs, crates/cli/src/setup/...
Replaced top-level Setup scaffolding with new Mod and Tools command variants; removed setup module’s SetupArgs/SetupCommand and ConfigArgs.
Arguments consolidation & config access
crates/cli/src/common.rs, crates/cli/src/build/mod.rs, crates/cli/src/run/mod.rs
Renamed CommonArgsBuildRunArgs, added doc comment for config field, removed #[command(flatten)] common_args fields from BuildArgs and RunArgs, and updated code to use br_args/build_run_args.config directly; changed a missing-module warning to an info message.
New mod subcommand and implementations
crates/cli/src/mod/mod.rs, crates/cli/src/mod/add.rs, crates/cli/src/mod/init.rs
Added mod CLI module with ModArgs and ModCommand (variants Init, Add); renamed ModuleArgsAddArgs; adjusted init/add argument wiring and dispatch (ModArgs::runModCommand::run → specific .run()).
Module parser target filtering
crates/module-parser/src/metadata.rs
Added filter to skip library targets whose name ends with "sdk" when resolving module crate names.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Build cmd #3 — touches the same CLI argument types and config/path wiring in build/run/common, likely overlapping changes.
  • add hard clippy rules and fix init #4 — modifies RunArgs/BuildRunArgs usage and adjusts config access patterns relevant to this refactor.
  • Skeleton + init|run cmd #2 — earlier refactor that introduced the Setup scaffolding and related argument types this PR removes or replaces.

Poem

🐰 I hopped through flags and args all day,

renamed a thing, then tucked it away.
Setup hopped out, Mod hopped in,
Add and Init begin to spin.
A tiny tweak, a quiet cheer—new paths are clear! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'landing a better organized cli structure' accurately captures the main objective of this PR, which reorganizes the CLI command structure by removing the Setup wrapper, introducing a new Mod subcommand, and consolidating common arguments.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/cli/src/common.rs`:
- Around line 95-97: Replace the stdout println! used when a local config module
is missing with stderr output to avoid polluting machine-readable stdout;
specifically change the println! call that prints "info: config module '{}' not
found locally, retrieving it from the registry" (the call referencing module.0)
to use eprintln! (or a structured logger writing to stderr) so the fallback
status message goes to stderr instead of stdout.

In `@crates/cli/src/mod/init.rs`:
- Around line 44-46: When self.local_path is Some we must not forward
self.subfolder (which defaults to "Init"); change the tuple in init.rs so the
second element is None instead of self.subfolder.clone() when entering local
template mode — i.e. replace (None, self.subfolder.clone(), None) with (None,
None, None) (or at least (None, None, None) for git, subfolder, branch) so local
templates don't get a forced subfolder; update any pattern/type expectations if
necessary to use Option<String>.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8840395 and 80926dc.

📒 Files selected for processing (11)
  • crates/cli/src/build/mod.rs
  • crates/cli/src/common.rs
  • crates/cli/src/main.rs
  • crates/cli/src/mod/add.rs
  • crates/cli/src/mod/init.rs
  • crates/cli/src/mod/mod.rs
  • crates/cli/src/run/mod.rs
  • crates/cli/src/setup/config.rs
  • crates/cli/src/setup/mod.rs
  • crates/cli/src/tools/mod.rs
  • crates/module-parser/src/metadata.rs
💤 Files with no reviewable changes (2)
  • crates/cli/src/setup/config.rs
  • crates/cli/src/setup/mod.rs

Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
crates/cli/src/mod/init.rs (1)

44-55: ⚠️ Potential issue | 🟠 Major

Local template mode still carries a forced subfolder via auto_path.

At Line 51, auto_path is always populated from subfolder, so --local-path still inherits "Init" implicitly instead of being truly local-path driven.

💡 Proposed fix
-        let (git, branch) = if self.local_path.is_some() {
+        let local_mode = self.local_path.is_some();
+        let (git, branch) = if local_mode {
             (None, None)
         } else {
             (self.git.clone(), self.branch.clone())
         };
         generate(GenerateArgs {
             template_path: TemplatePath {
-                auto_path: self.subfolder.clone(),
+                auto_path: if local_mode { None } else { self.subfolder.clone() },
                 git,
                 path: self.local_path.clone(),
                 subfolder: None, // This is only used when git, path and favorite are not specified
                 branch,
In cargo-generate, when `TemplatePath.path` is provided (local template mode), is `TemplatePath.auto_path` still applied to resolve the final template directory?
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/cli/src/mod/init.rs` around lines 44 - 55, The template auto_path
(TemplatePath.auto_path) is always set from self.subfolder causing local-path
mode to still force a subfolder; update the GenerateArgs/TemplatePath
construction so that when self.local_path.is_some() the auto_path is None (or
only set when not using local_path), i.e. branch the value used for
TemplatePath.auto_path based on self.local_path (or reuse the earlier git/branch
conditional) so TemplatePath.auto_path is cleared in local template mode.
🧹 Nitpick comments (1)
crates/module-parser/src/metadata.rs (1)

15-15: Consider adding documentation and refining the "sdk" filter.

A few observations on this new filter:

  1. Missing rationale: There's no comment explaining why SDK targets should be excluded. Future maintainers will wonder about the intent.

  2. Case sensitivity: ends_with("sdk") is case-sensitive, so targets named "MySdk" or "MySDK" would not be filtered. Verify this is the intended behavior.

  3. Magic string: Consider extracting "sdk" to a constant with a descriptive name.

💡 Suggested improvement
-            if t.is_lib() && !t.name.ends_with("sdk") {
+            // Skip SDK library targets as they are auxiliary crates not intended for module registration
+            if t.is_lib() && !t.name.ends_with("sdk") {

Or, if case-insensitivity is desired:

-            if t.is_lib() && !t.name.ends_with("sdk") {
+            // Skip SDK library targets as they are auxiliary crates not intended for module registration
+            if t.is_lib() && !t.name.to_lowercase().ends_with("sdk") {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/module-parser/src/metadata.rs` at line 15, Add a short comment above
the filter in metadata.rs explaining why library targets with an SDK suffix are
excluded, extract the literal "sdk" into a clearly named constant (e.g.,
SDK_SUFFIX) and use it in the predicate, and make the check case-insensitive
(e.g., compare lowercase/uppercased versions of t.name or use a case-insensitive
comparison) so names like "MySdk" or "MySDK" are also filtered; retain the use
of t.is_lib() and t.name to locate the condition to change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@crates/cli/src/mod/init.rs`:
- Around line 44-55: The template auto_path (TemplatePath.auto_path) is always
set from self.subfolder causing local-path mode to still force a subfolder;
update the GenerateArgs/TemplatePath construction so that when
self.local_path.is_some() the auto_path is None (or only set when not using
local_path), i.e. branch the value used for TemplatePath.auto_path based on
self.local_path (or reuse the earlier git/branch conditional) so
TemplatePath.auto_path is cleared in local template mode.

---

Nitpick comments:
In `@crates/module-parser/src/metadata.rs`:
- Line 15: Add a short comment above the filter in metadata.rs explaining why
library targets with an SDK suffix are excluded, extract the literal "sdk" into
a clearly named constant (e.g., SDK_SUFFIX) and use it in the predicate, and
make the check case-insensitive (e.g., compare lowercase/uppercased versions of
t.name or use a case-insensitive comparison) so names like "MySdk" or "MySDK"
are also filtered; retain the use of t.is_lib() and t.name to locate the
condition to change.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 80926dc and d70e955.

📒 Files selected for processing (11)
  • crates/cli/src/build/mod.rs
  • crates/cli/src/common.rs
  • crates/cli/src/main.rs
  • crates/cli/src/mod/add.rs
  • crates/cli/src/mod/init.rs
  • crates/cli/src/mod/mod.rs
  • crates/cli/src/run/mod.rs
  • crates/cli/src/setup/config.rs
  • crates/cli/src/setup/mod.rs
  • crates/cli/src/tools/mod.rs
  • crates/module-parser/src/metadata.rs
💤 Files with no reviewable changes (2)
  • crates/cli/src/setup/mod.rs
  • crates/cli/src/setup/config.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/cli/src/common.rs

@Bechma Bechma merged commit 3baa5ca into cyberfabric:main Mar 2, 2026
1 check passed
@Bechma Bechma deleted the structure-cli branch March 2, 2026 22:35
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.

1 participant