Skip to content

Conversation

@1daidai1
Copy link
Collaborator

@1daidai1 1daidai1 commented Aug 15, 2025

image image

Summary by CodeRabbit

  • New Features
    • Added a --quiet (-Q) option to calloc and crun to suppress informational console messages.
    • Routine status updates (task ID allocation, resource allocation, IO-forward readiness) are hidden when quiet is enabled; errors and final outputs remain visible.
    • Default behavior unchanged; no changes to public APIs or command workflows.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 15, 2025

Walkthrough

Add a global FlagQuiet boolean to both calloc and crun commands and suppress several informational stdout prints in specific state handlers when FlagQuiet is true. No control-flow, state transitions, or error handling changes.

Changes

Cohort / File(s) Summary
Quiet flag wiring
internal/calloc/cmd.go, internal/crun/cmd.go
Add exported FlagQuiet bool and register --quiet/-Q CLI flag (default false) for the calloc and crun commands.
Conditional informational prints
internal/calloc/calloc.go, internal/crun/crun.go
Gate specific stdout prints with if !FlagQuiet { ... } in state handlers (e.g., Task ID allocated, Allocated craned nodes, Task IO forward ready). No other logic or error handling changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Pay attention to correct package-level variable visibility and flag binding in both packages.
  • Verify the scoped uses of FlagQuiet in state handlers reference the correct package variable.

Suggested reviewers

  • L-Xiafeng
  • RileyWen

Poem

Quiet switch set, my nose takes note,
Hushed logs tiptoe along the moat.
Tasks still sprint, the burrow hums,
Softly now, no trumpet drums.
A rabbit nods — serene, remote. 🐇✨

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 accurately and concisely summarizes the main change: adding a quiet mode flag (-Q/--quiet) to the calloc and crun commands.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev/callocquiet

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b130c21 and a6409e4.

📒 Files selected for processing (4)
  • internal/calloc/calloc.go (2 hunks)
  • internal/calloc/cmd.go (2 hunks)
  • internal/crun/cmd.go (2 hunks)
  • internal/crun/crun.go (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • internal/crun/cmd.go
  • internal/calloc/calloc.go
  • internal/calloc/cmd.go
  • internal/crun/crun.go

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
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: 1

🔭 Outside diff range comments (1)
internal/calloc/calloc.go (1)

214-221: Informational print gated correctly; route the failure message to stderr

The “Allocated craned nodes” print is informational and now gated — good. The failure message right below still goes to stdout; it should go to stderr for proper CLI semantics.

Apply:

-					fmt.Println("Failed to allocate task resource. Exiting...")
+					_, _ = fmt.Fprintln(os.Stderr, "Failed to allocate task resource. Exiting...")
🧹 Nitpick comments (3)
internal/calloc/calloc.go (1)

183-186: Gating informational print behind quiet is correct

Only the informational “Task id allocated” goes through fmt.Printf and is now suppressed by --quiet. Control flow and error handling remain unchanged.

Optionally align the message with crun’s wording for consistency across tools:

-					fmt.Printf("Task id allocated: %d\n", taskId)
+					fmt.Printf("Task id allocated: %d, waiting resources.\n", taskId)
internal/crun/crun.go (2)

301-303: Allocated-nodes informational print gated — consider punctuation parity with calloc

Behavior is correct. For a consistent user experience with calloc, consider adding a trailing period.

-					fmt.Printf("Allocated craned nodes: %s\n", cforedPayload.AllocatedCranedRegex)
+					fmt.Printf("Allocated craned nodes: %s.\n", cforedPayload.AllocatedCranedRegex)

349-351: Quiet gating for “io forward ready” is appropriate

Good call to suppress this purely informational line in quiet mode.

If you find yourself adding more gated prints, consider a small helper in each package to avoid repetition:

// in package crun
func printInfo(format string, a ...any) {
	if !FlagQuiet {
		fmt.Printf(format, a...)
	}
}

Then replace fmt.Printf(...) with printInfo(...).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 673530d and 8a5c5a4.

📒 Files selected for processing (4)
  • internal/calloc/CmdArgParser.go (2 hunks)
  • internal/calloc/calloc.go (2 hunks)
  • internal/crun/CmdArgParser.go (2 hunks)
  • internal/crun/crun.go (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
internal/calloc/calloc.go (2)
internal/crun/CmdArgParser.go (1)
  • FlagQuiet (61-61)
internal/calloc/CmdArgParser.go (1)
  • FlagQuiet (55-55)
internal/crun/crun.go (2)
internal/crun/CmdArgParser.go (1)
  • FlagQuiet (61-61)
internal/calloc/CmdArgParser.go (1)
  • FlagQuiet (55-55)
internal/crun/CmdArgParser.go (1)
internal/calloc/CmdArgParser.go (2)
  • RootCmd (57-68)
  • FlagQuiet (55-55)
internal/calloc/CmdArgParser.go (1)
internal/crun/CmdArgParser.go (2)
  • RootCmd (63-73)
  • FlagQuiet (61-61)
🔇 Additional comments (4)
internal/crun/CmdArgParser.go (1)

60-62: Quiet flag state added — looks good and consistent with calloc

The new exported FlagQuiet and its placement with other flags is consistent and clear.

internal/calloc/CmdArgParser.go (2)

54-56: Quiet flag state added — mirrors crun and reads well

Exported FlagQuiet and its position next to FlagHold is consistent with crun’s CmdArgParser.


103-103: -Q/--quiet registration matches crun — consistent UX

Binding and help text match crun. Good consistency across binaries.

internal/crun/crun.go (1)

256-258: TaskId informational print now respects --quiet — good

This keeps user-facing noise down without altering state handling or error paths.

@Nativu5
Copy link
Collaborator

Nativu5 commented Sep 13, 2025

@1daidai1 Rebase 一下就合并吧。

@Nativu5 Nativu5 changed the title Add calloc/crun -Q/--quiet feat: Add calloc/crun -Q/--quiet Sep 13, 2025
@1daidai1
Copy link
Collaborator Author

@Nativu5 done

Copy link
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: 1

🧹 Nitpick comments (3)
internal/calloc/cmd.go (1)

54-55: Consider not exporting FlagQuiet.

It’s only used within this package; making it unexported (flagQuiet) reduces public surface and avoids cross‑pkg name collisions.

Apply:

-   FlagHold  bool
-   FlagQuiet bool
+   FlagHold   bool
+   flagQuiet  bool

And update inits/uses accordingly.

internal/crun/cmd.go (2)

60-61: Limit export surface for FlagQuiet.

Same note as calloc: consider unexported flagQuiet unless external packages need it.

Apply:

-   FlagHold  bool
-   FlagQuiet bool
+   FlagHold   bool
+   flagQuiet  bool

And adjust references.


117-117: Make quiet persistent for consistency with debug-level.
Change RootCmd.Flags -> RootCmd.PersistentFlags so -Q is inherited by subcommands. Verified FlagQuiet gates state messages in internal/crun/crun.go (lines 256, 301, 349) and no other -Q flags found under internal/crun. Apply:

- RootCmd.Flags().BoolVarP(&FlagQuiet, "quiet", "Q", false, "Quiet mode (suppress informational messages)")
+ RootCmd.PersistentFlags().BoolVarP(&FlagQuiet, "quiet", "Q", false, "Quiet mode (suppress informational messages)")
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8a5c5a4 and b130c21.

📒 Files selected for processing (4)
  • internal/calloc/calloc.go (2 hunks)
  • internal/calloc/cmd.go (2 hunks)
  • internal/crun/cmd.go (2 hunks)
  • internal/crun/crun.go (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/calloc/calloc.go
  • internal/crun/crun.go
🧰 Additional context used
🧬 Code graph analysis (2)
internal/calloc/cmd.go (1)
internal/crun/cmd.go (1)
  • FlagQuiet (61-61)
internal/crun/cmd.go (1)
internal/calloc/cmd.go (2)
  • RootCmd (57-68)
  • FlagQuiet (55-55)
🔇 Additional comments (2)
internal/calloc/cmd.go (1)

103-103: Quiet flag wiring: looks good.

The --quiet/-Q flag registration is correct and consistent with existing flags.

internal/crun/cmd.go (1)

117-117: Quiet flag wiring: looks good.

--quiet/-Q registration is correct; uppercase -Q avoids conflict with existing -q (qos).

@L-Xiafeng
Copy link
Collaborator

need rebase

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