Skip to content

fix: case-insensitive arguments.#42

Open
Skyrion9 wants to merge 1 commit into
rodrigomatta:mainfrom
Skyrion9:case-sensitivity
Open

fix: case-insensitive arguments.#42
Skyrion9 wants to merge 1 commit into
rodrigomatta:mainfrom
Skyrion9:case-sensitivity

Conversation

@Skyrion9

@Skyrion9 Skyrion9 commented Jul 15, 2026

Copy link
Copy Markdown
  • Normalize arguments to lowercase before comparison so that --codec-CPU etc. will still be accepted as valid flags instead of being silenlty ignored.

Summary by CodeRabbit

  • New Features
    • Command-line options are now recognized regardless of letter casing, including model, output, server, host, port, logging, and help options.
    • Mixed-case flags such as --Log-Level are accepted consistently.

- Normalize arguments to lowercase before comparison so that --codec-CPU etc. will still be accepted as valid flags instead of being silenlty ignored.
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Command-line parsing in src/main.cpp lowercases dash-prefixed arguments before matching them, making the supported options case-insensitive while preserving existing option behavior.

Changes

CLI option parsing

Layer / File(s) Summary
Normalize and dispatch CLI options
src/main.cpp
Dash-prefixed arguments are normalized to lowercase before matching model, tokenizer, generation, codec, logging, server, host, port, and help options.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 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 change: making command-line arguments case-insensitive.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Warning

⚠️ This pull request shows signs of AI-generated slop (defensive_cruft). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main.cpp`:
- Around line 158-164: Restrict the lowercase transformation in the
argument-normalization block to dash-prefixed flags longer than two characters,
preserving case for short options such as -M, -H, and -P. Keep the existing
long-option matching flow unchanged and ensure comparisons against uppercase
short flags remain reachable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8c0af40f-6075-497b-940c-5bd4b55fdd7f

📥 Commits

Reviewing files that changed from the base of the PR and between 2c33261 and f140614.

📒 Files selected for processing (1)
  • src/main.cpp

Comment thread src/main.cpp
Comment on lines +158 to +164

// Normalize flag arguments to lowercase for case-insensitive matching
std::string arg_lower = arg;
if (!arg.empty() && arg[0] == '-') {
std::transform(arg_lower.begin(), arg_lower.end(), arg_lower.begin(),
[](unsigned char c) { return static_cast<char>(std::tolower(c)); });
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Case-insensitive short options create collisions and dead code.

Lowercasing all dash-prefixed arguments introduces critical logic errors for short options that rely on case sensitivity:

  • -M (Metal) is lowercased to -m, colliding with --model at line 166.
  • -H (Host) is lowercased to -h, colliding with --help at line 234.
  • -P (Port) is lowercased to -p, which skips the condition chain entirely.

Additionally, comparisons like arg_lower == "-M" and arg_lower == "-H" become dead code because arg_lower will never contain uppercase letters after the transformation.

To fix this while keeping long options case-insensitive, restrict the lowercase transformation to flags longer than 2 characters. This correctly preserves standard short flags like -M, -H, and -P.

🐛 Proposed fix
-        if (!arg.empty() && arg[0] == '-') {
+        if (arg.length() > 2 && arg[0] == '-') {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Normalize flag arguments to lowercase for case-insensitive matching
std::string arg_lower = arg;
if (!arg.empty() && arg[0] == '-') {
std::transform(arg_lower.begin(), arg_lower.end(), arg_lower.begin(),
[](unsigned char c) { return static_cast<char>(std::tolower(c)); });
}
// Normalize flag arguments to lowercase for case-insensitive matching
std::string arg_lower = arg;
if (arg.length() > 2 && arg[0] == '-') {
std::transform(arg_lower.begin(), arg_lower.end(), arg_lower.begin(),
[](unsigned char c) { return static_cast<char>(std::tolower(c)); });
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main.cpp` around lines 158 - 164, Restrict the lowercase transformation
in the argument-normalization block to dash-prefixed flags longer than two
characters, preserving case for short options such as -M, -H, and -P. Keep the
existing long-option matching flow unchanged and ensure comparisons against
uppercase short flags remain reachable.

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