Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): Add CLI flags for controlling output sections and content processing #236

Merged
merged 1 commit into from
Dec 31, 2024

Conversation

yamadashy
Copy link
Owner

@yamadashy yamadashy commented Dec 31, 2024

This pull request adds new CLI flags to provide users with more control over the structure and content of Repomix output. These flags allow users to:

  • Disable the file summary section.
  • Disable the directory structure section.
  • Enable comment removal from supported file types.
  • Enable removal of empty lines.

ref
#206 (comment)

Checklist

  • Run npm run test
  • Run npm run lint

Copy link

stackblitz bot commented Dec 31, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
Contributor

coderabbitai bot commented Dec 31, 2024

📝 Walkthrough

Walkthrough

This pull request introduces new command-line options for the Repomix tool to enhance output configurability. The changes span across multiple files, including README.md, src/cli/actions/defaultAction.ts, src/cli/cliRun.ts, and tests/cli/actions/defaultAction.test.ts. The new options allow users to disable file summary and directory structure output, remove comments from supported file types, and remove empty lines from the output. These modifications provide more flexibility in how the tool generates and presents information.

Changes

File Change Summary
README.md Added documentation for new CLI options: --no-file-summary, --no-directory-structure, --remove-comments, --remove-empty-lines
src/cli/actions/defaultAction.ts Updated buildCliConfig to handle new output configuration options by merging them into cliConfig.output
src/cli/cliRun.ts Extended CliOptions interface with new optional properties and added corresponding command-line options to the program instance
tests/cli/actions/defaultAction.test.ts Added test cases to verify the handling of new output configuration flags

Possibly related PRs

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Dec 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.26%. Comparing base (5821fb1) to head (42401bb).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #236      +/-   ##
==========================================
+ Coverage   92.20%   92.26%   +0.05%     
==========================================
  Files          44       44              
  Lines        2090     2106      +16     
  Branches      458      462       +4     
==========================================
+ Hits         1927     1943      +16     
  Misses        163      163              

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

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

🧹 Nitpick comments (1)
src/cli/actions/defaultAction.ts (1)

127-129: Handle unexpected blank lines.

Removing empty lines can sometimes introduce unintended concatenations, especially in files where line breaks are syntactically meaningful. Confirm that existing tests catch such edge cases.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5821fb1 and 42401bb.

📒 Files selected for processing (4)
  • README.md (1 hunks)
  • src/cli/actions/defaultAction.ts (1 hunks)
  • src/cli/cliRun.ts (2 hunks)
  • tests/cli/actions/defaultAction.test.ts (1 hunks)
🔇 Additional comments (14)
src/cli/cliRun.ts (2)

29-32: Add default values or handle undefined states.

While these optional booleans provide flexibility, consider explicitly setting default values or handling undefined states. This ensures predictable behavior when the user doesn’t pass these flags.


49-52: Ensure consistent naming and usage.

These CLI options follow a negative/affirmative pattern (--no-... versus --remove-...). Confirm that this approach remains intuitive for users. Documentation in the README appears clear, but double-check for any inconsistent references.

src/cli/actions/defaultAction.ts (3)

118-120: Good practice in handling fileSummary.

This check mirrors standard CLI patterns. The condition sets fileSummary in the output object. The approach is consistent.


121-123: Consistent approach for directoryStructure.

Same pattern as fileSummary. Ensures clarity when turning directory structure on or off.


124-126: Validate removal logic for comments.

Removing comments may affect certain file types that rely on doc comments. Ensure that your removal logic won’t break docstring-based frameworks or tools.

tests/cli/actions/defaultAction.test.ts (8)

166-185: Comprehensive test coverage for --no-file-summary.

These tests accurately confirm that the fileSummary flag is set to false. Well done.


186-203: Comprehensive test coverage for --file-summary.

These tests ensure fileSummary is set to true when specified. This consistency between the test and the CLI logic is good.


205-223: Thorough testing of --no-directory-structure.

Checks are aligned with the condition in the CLI config. Good job verifying the merged config.


224-241: Ensure directoryStructure is tested for both states.

The explicit test for true helps to confirm correct behavior. Looks consistent.


243-261: Validate comment removal.

This test suite ensures removeComments: true is passed along. Confirm that underlying logic handles multiple file types properly.


262-279: Confirm no-remove-comments usage.

Testing the false scenario helps avoid regression. Reassuring coverage for toggling behavior.


281-299: Check the removeEmptyLines implementation.

These tests adequately verify that removeEmptyLines is set to true. Evaluate logs or code coverage to confirm this code path runs for a variety of file formats.


300-317: Thorough coverage of no-remove-empty-lines.

Again, specifying false ensures that empty lines remain intact. Good job covering both states.

README.md (1)

315-318: Clear explanation of new flags.

These lines in the documentation provide excellent clarity on the new flags. They match the CLI code changes and should reduce confusion for users.

@yamadashy yamadashy merged commit 081c567 into main Dec 31, 2024
37 checks passed
@yamadashy yamadashy deleted the feat/cli-flags branch December 31, 2024 18:07
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