Skip to content

simplify CLI arg parsing - #228

Open
nt591 wants to merge 1 commit into
vllm-project:mainfrom
nt591:nzthomas/cli-parsing
Open

simplify CLI arg parsing#228
nt591 wants to merge 1 commit into
vllm-project:mainfrom
nt591:nzthomas/cli-parsing

Conversation

@nt591

@nt591 nt591 commented Aug 31, 2026

Copy link
Copy Markdown

Purpose

Code legibility, general Rust-iness, and hopefully being useful to others.

Another driveby as I was working through the codebase. Today, CLI parsing walks the list of Clap args twice. Once for prefill, then another time for non-prefill args. We can do this once using standard iterator traversal which also simpified some of the index checks needed earlier.

This also fixes (I hope) a latent bug where --prefill --port 3000 would silently drop instead of making noise about a missing URL.

Test Plan

cargo check, cargo fmt, clippy, unit tests (new and old)

Test Result

clean.

Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results

Comment thread src/main.rs Outdated
}
Some(arg) if !arg.starts_with("-") => {
// assume to be a port
let port = arg.parse::<u16>().ok();

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this is intended to match with existing behavior, but in my opinion this branch should be something like let port = arg.parse::<u16>().ok_or(format!("Invalid input for port: {arg:?}"))

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 69af8e9d98

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/main.rs Outdated
Comment on lines +41 to +42
let port = arg.parse::<u16>().ok();
args.next();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reject malformed bootstrap ports

When --prefill is followed by a malformed or out-of-range bootstrap port, such as --prefill http://prefill:8000 65536, .ok() converts the parse failure to None and the next line still consumes the argument. The router therefore accepts the typo and may silently use the default port 8998 (src/routers/http/vllm_pd_router.rs:1663) instead of refusing the invalid configuration; preserve the argument for Clap to reject or return an explicit parsing error.

Useful? React with 👍 / 👎.

@nt591
nt591 force-pushed the nzthomas/cli-parsing branch from 69af8e9 to 86c190f Compare August 31, 2026 20:30
Another driveby as I was working through the codebase. Today, CLI parsing walks the list of Clap args twice. Once for prefill, then another time for non-prefill args. We can do this once using standard iterator traversal which also simpified some of the index checks needed earlier.

Signed-off-by: Nikhil Thomas <nikhil@nthomas.org>
@nt591
nt591 force-pushed the nzthomas/cli-parsing branch from 86c190f to 09ce919 Compare August 31, 2026 20:57
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