Skip to content

refactor: add colors to --help output and uniform logging#374

Merged
2bndy5 merged 1 commit into
mainfrom
cli-refactor
Jun 19, 2026
Merged

refactor: add colors to --help output and uniform logging#374
2bndy5 merged 1 commit into
mainfrom
cli-refactor

Conversation

@2bndy5

@2bndy5 2bndy5 commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Following DRY principal, I unified all logging implementation used in the workspace to clang-tools-manager crate.

I also took the time to add colors to all --help output. These colors still adhere to FORCE, CLICOLOR, CLICOLOR_FORCE, and NO_COLOR env vars. The color theme resides in the same logger module used by each binary in the workspace.

Lastly, I made clang-tools CLI's --tool argument into a repeatable positional argument (with the same default value).

PS - I adjusted cargo-nextest config to auto-cancel on tests that get caught in an infinite loop/hang. This happened recently in CI, and had it to be cancel manually.

Summary by CodeRabbit

  • New Features

    • Enhanced CLI help output with improved styling and formatting.
  • Bug Fixes

    • Adjusted test timeout configuration for improved reliability.
  • Documentation

    • Updated CLI documentation reflecting simplified argument handling and new options.
  • Chores

    • Reorganized internal dependencies and consolidated logger initialization.

Following DRY principal, I unified all logging implementation used in the workspace to clang-tools-manager crate.

I also took the time to add colors to all `--help` output. These colors still adhere to `FORCE`, `CLICOLOR`, `CLICOLOR_FORCE`, and `NO_COLOR` env vars.
The color theme resides in the same logger module used by each binary in the workspace.

Lastly, I made clang-tools CLI's `--tool` argument into a repeatable positional argument (with the same default value).

PS - I adjusted cargo-nextest config to auto-cancel on tests that get caught in an infinite loop/hang. This happened recently in CI, and had to be cancel manually.
@2bndy5 2bndy5 added the enhancement New feature or request label Jun 19, 2026
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: cb1b4c5a-b9d1-46b5-9a3d-14b3f4ba1c23

📥 Commits

Reviewing files that changed from the base of the PR and between c149eea and 9ddc45d.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (17)
  • .config/nextest.toml
  • Cargo.toml
  • clang-tools-manager/Cargo.toml
  • clang-tools-manager/README.md
  • clang-tools-manager/src/lib.rs
  • clang-tools-manager/src/logger.rs
  • clang-tools-manager/src/main.rs
  • clang-tools-manager/tests/common.rs
  • clang-tools-manager/tests/pypi.rs
  • clang-tools-manager/tests/static_dist.rs
  • cpp-linter/Cargo.toml
  • cpp-linter/src/clang_tools/mod.rs
  • cpp-linter/src/cli/mod.rs
  • cpp-linter/src/lib.rs
  • cpp-linter/src/rest_client.rs
  • cpp-linter/src/run.rs
  • cpp-linter/tests/paginated_changed_files.rs
💤 Files with no reviewable changes (3)
  • clang-tools-manager/tests/common.rs
  • Cargo.toml
  • cpp-linter/src/lib.rs

📝 Walkthrough

Walkthrough

The logger module is moved from cpp-linter into clang-tools-manager, gaining a new CLI_HELP_STYLE constant and a renamed try_init_logger function. All call sites in both crates are updated accordingly. The --tool CLI argument changes from Option<Vec<ClangTool>> to Vec<ClangTool> with explicit defaults, and the colored dependency is moved from workspace-level to a local pin.

Changes

Logger consolidation, CLI refactor, and dependency cleanup

Layer / File(s) Summary
Logger module relocated and extended in clang-tools-manager
clang-tools-manager/src/lib.rs, clang-tools-manager/src/logger.rs
lib.rs declares pub mod logger. logger.rs adds the exported CLI_HELP_STYLE clap Styles constant, extends SimpleLogger::log to filter on clang_tools module paths in addition to cpp_linter, and renames the exported init function from try_init to try_init_logger. The unit test is updated accordingly.
Dependency and feature cleanup
Cargo.toml, clang-tools-manager/Cargo.toml, cpp-linter/Cargo.toml
colored is removed from workspace dependencies and re-pinned locally in clang-tools-manager. clap loses its explicit derive feature there. cpp-linter enables the clang-tools-manager bin feature, drops colored, and removes dep:colored from its own bin feature definition.
clang-tools-manager binary: tool arg and logger wiring
clang-tools-manager/src/main.rs
Imports CLI_HELP_STYLE and try_init_logger from the crate's own logger module and applies CLI_HELP_STYLE to the clap command. Changes the --tool field from Option<Vec<ClangTool>> to Vec<ClangTool> with ClangFormat/ClangTidy defaults; main iterates options.tool directly.
cpp-linter: remove own logger, wire to clang-tools-manager
cpp-linter/src/lib.rs, cpp-linter/src/run.rs, cpp-linter/src/cli/mod.rs
lib.rs removes pub mod logger. run.rs imports and calls try_init_logger from clang_tools_manager. cli/mod.rs imports CLI_HELP_STYLE and applies it via styles(...) with color = Auto on the Cli command attribute.
Test logger wiring updated across both crates
clang-tools-manager/tests/..., cpp-linter/src/clang_tools/mod.rs, cpp-linter/src/rest_client.rs, cpp-linter/tests/paginated_changed_files.rs
Integration tests in both crates replace common::initialize_logger() or local logger::try_init() calls with clang_tools_manager::logger::try_init_logger(), conditionally gated on the bin feature where appropriate. The now-empty common.rs helper is removed.
README and nextest config
clang-tools-manager/README.md, .config/nextest.toml
README updates the clang-tools --help snippet to document the new positional [TOOL]... argument and --mod-sys/--no-mod-sys options. nextest.toml changes profile.all slow-timeout from a flat 60s to period = "30s" with terminate-after = 8.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • cpp-linter/cpp-linter-rs#366: Edits the same clang-tools-manager/README.md CLI help documentation section, including the rendered clang-tools --help output and option descriptions.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding colored help output and refactoring logging across the workspace.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.43%. Comparing base (c149eea) to head (9ddc45d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #374      +/-   ##
==========================================
- Coverage   92.43%   92.43%   -0.01%     
==========================================
  Files          23       23              
  Lines        3649     3646       -3     
==========================================
- Hits         3373     3370       -3     
  Misses        276      276              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@2bndy5 2bndy5 marked this pull request as ready for review June 19, 2026 11:25
@2bndy5 2bndy5 merged commit f352be2 into main Jun 19, 2026
85 checks passed
@2bndy5 2bndy5 deleted the cli-refactor branch June 19, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant