Skip to content

Feat/cli flags#324

Merged
yamadashy merged 5 commits intoyamadashy:mainfrom
massdo:feat/cli-flags
Jan 28, 2025
Merged

Feat/cli flags#324
yamadashy merged 5 commits intoyamadashy:mainfrom
massdo:feat/cli-flags

Conversation

@massdo
Copy link
Contributor

@massdo massdo commented Jan 27, 2025

Add missing CLI flags

related to issue #316
Hi @yamadashy 👋

I add each flag in separate commit for better visibility.
I stick to the existing tests, i hope everything's good, tell me otherwise.

Checklist

  • Run npm run test
  • Run npm run lint

@codecov
Copy link

codecov bot commented Jan 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.27%. Comparing base (27a3309) to head (157440e).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #324      +/-   ##
==========================================
+ Coverage   90.19%   90.27%   +0.07%     
==========================================
  Files          48       48              
  Lines        2488     2508      +20     
  Branches      514      519       +5     
==========================================
+ Hits         2244     2264      +20     
  Misses        244      244              

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2025

Warning

Rate limit exceeded

@yamadashy has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 59 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 8d359aa and 157440e.

📒 Files selected for processing (5)
  • README.md (4 hunks)
  • src/cli/actions/defaultAction.ts (2 hunks)
  • src/cli/cliRun.ts (4 hunks)
  • tests/cli/actions/defaultAction.test.ts (1 hunks)
  • tests/cli/cliRun.test.ts (1 hunks)
📝 Walkthrough

Walkthrough

The pull request introduces several new command-line options to the Repomix tool, enhancing its configurability and flexibility. The changes span multiple files, including README.md, src/cli/actions/defaultAction.ts, and src/cli/cliRun.ts. The new options include --no-gitignore to disable .gitignore file usage, --no-default-patterns to disable default ignore patterns, --header-text for custom header text, --instruction-file-path to specify a custom instructions file, and --include-empty-directories to include empty directories in the output. Corresponding updates were made to the CLI configuration handling and test suites to support these new options, ensuring that users can now more precisely control the tool's behavior through command-line arguments.

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI
    participant ConfigBuilder
    participant OutputGenerator

    User->>CLI: Invoke with new options
    CLI->>ConfigBuilder: Build configuration
    ConfigBuilder-->>CLI: Updated config with new options
    CLI->>OutputGenerator: Generate output
    OutputGenerator-->>User: Customized output based on options
Loading

Possibly related PRs


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
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 (3)
src/cli/cliRun.ts (1)

51-52: Consider adding descriptions to the CLI options.

While the implementation is correct, adding descriptions to these new CLI options would improve the user experience when they run --help.

Apply this diff to add descriptions:

-      .option('--no-gitignore', 'disable .gitignore file usage')
-      .option('--no-default-patterns', 'disable default patterns')
+      .option('--no-gitignore', 'disable .gitignore file usage for ignoring files')
+      .option('--no-default-patterns', 'disable default ignore patterns like node_modules, .git, etc.')
       .option('-c, --config <path>', 'path to a custom config file')
       .option('--copy', 'copy generated output to system clipboard')
       .option('--top-files-len <number>', 'specify the number of top files to display', Number.parseInt)
       .option('--output-show-line-numbers', 'add line numbers to each line in the output')
       .option('--style <type>', 'specify the output style (plain, xml, markdown)')
       .option('--parsable-style', 'by escaping and formatting, ensure the output is parsable as a document of its type')
-      .option('--header-text <text>', 'specify the header text')
+      .option('--header-text <text>', 'specify custom header text to be added at the top of the output')
       .option('--no-file-summary', 'disable file summary section output')
       .option('--no-directory-structure', 'disable directory structure section output')
       .option('--remove-comments', 'remove comments')
       .option('--remove-empty-lines', 'remove empty lines')
       .option('--verbose', 'enable verbose logging for detailed output')
       .option('--init', 'initialize a new repomix.config.json file')
       .option('--global', 'use global configuration (only applicable with --init)')
       .option('--remote <url>', 'process a remote Git repository')
       .option('--token-count-encoding <encoding>', 'specify token count encoding (e.g., o200k_base, cl100k_base)')
-      .option('--instruction-file-path <path>', 'path to a file containing detailed custom instructions')
-      .option('--include-empty-directories', 'include empty directories in the output')
+      .option('--instruction-file-path <path>', 'path to a file containing detailed custom instructions for processing')
+      .option('--include-empty-directories', 'include empty directories in the directory structure output')

Also applies to: 59-59, 74-75

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

361-379: Consider adding negative test cases.

While the happy path test cases are well-covered, consider adding negative test cases to verify error handling:

  1. Invalid instruction file path
  2. Empty header text
  3. Invalid patterns

Here's an example of a negative test case:

it('should handle invalid instruction file path', async () => {
  const options: CliOptions = {
    instructionFilePath: 'non/existent/path.txt',
  };

  await expect(runDefaultAction('.', process.cwd(), options))
    .rejects
    .toThrow('Invalid instruction file path');
});

Also applies to: 381-399, 401-419, 421-439, 441-459

README.md (1)

587-587: Fix indentation in the priority order list.

The indentation of items 3 and 4 in the priority order list is inconsistent with the previous items.

Apply this diff to fix the formatting:

1. Custom patterns `ignore.customPatterns`
2. `.repomixignore`
-3. `.gitignore` (if `ignore.useGitignore` is true and `--no-gitignore` is not used)
-4. Default patterns (if `ignore.useDefaultPatterns` is true and `--no-default-patterns` is not used)
+3. `.gitignore` (if `ignore.useGitignore` is true and `--no-gitignore` is not used)
+4. Default patterns (if `ignore.useDefaultPatterns` is true and `--no-default-patterns` is not used)

Also applies to: 589-589, 600-601

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 27a3309 and 8d359aa.

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

18-19: LGTM! Interface changes look good.

The new optional properties added to the CliOptions interface align well with the PR objectives of adding missing CLI flags.

Also applies to: 33-33, 38-39

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

103-108: LGTM! Gitignore and default patterns handling looks good.

The implementation correctly spreads the existing ignore configuration before adding new properties.


139-141: Consider validating file paths.

While the implementation is correct, it would be good to validate the instructionFilePath to ensure it exists and is readable before proceeding.

Run the following script to check if the file path validation is handled elsewhere:

Also applies to: 145-150

tests/cli/cliRun.test.ts (1)

224-246: LGTM! Test coverage looks comprehensive.

The test cases thoroughly verify the handling of all new CLI options, including edge cases and default values.

Also applies to: 248-258, 260-282

README.md (1)

407-408: LGTM! New CLI flags are well-documented.

The new command-line options are clearly documented with appropriate descriptions that align with their functionality.

Also applies to: 410-410, 425-426

@yamadashy
Copy link
Owner

Hi, @massdo !
Thank you as always for your contributions!
I've verified all command functionalities on my end, and the diff looks flawless!

Thank you for the clean implementation!
Merging this now. 🚀

@yamadashy yamadashy merged commit 3eff6ea into yamadashy:main Jan 28, 2025
53 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 8, 2025
2 tasks
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.

2 participants