-
Notifications
You must be signed in to change notification settings - Fork 85
chore: move parseCliArgs to args-parser MCP-298 #2595
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the argument parsing logic by moving the core parseCliArgs functionality from cli-repl to the arg-parser package, improving code organization and separation of concerns. A new wrapper function parseMongoshCliArgs is introduced in cli-repl to handle CLI-specific error formatting.
Key changes:
- Moved
parseCliArgs,verifyCliArguments,getLocale, and related logic fromcli-repl/arg-parsertoarg-parser/arg-parser - Created
parseMongoshCliArgswrapper incli-replto handleUnknownCliArgumentErrorwith CLI-specific formatting - Relocated test suite from
cli-repltoarg-parserpackage - Moved
yargs-parserdependency fromcli-repltoarg-parserpackage
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/cli-repl/src/run.ts | Updated import and function call to use parseMongoshCliArgs |
| packages/cli-repl/src/arg-parser.ts | Replaced implementation with thin wrapper that catches UnknownCliArgumentError and formats CLI errors |
| packages/cli-repl/src/arg-parser.spec.ts | Reduced to minimal tests verifying the wrapper functionality |
| packages/cli-repl/package.json | Removed yargs-parser dependency |
| packages/arg-parser/src/index.ts | Exported parseCliArgs and UnknownCliArgumentError |
| packages/arg-parser/src/arg-parser.ts | Added core argument parsing implementation moved from cli-repl |
| packages/arg-parser/src/arg-parser.spec.ts | Added comprehensive test suite moved from cli-repl |
| packages/arg-parser/package.json | Added yargs-parser dependency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
addaleax
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm yeah, the shell-api complaint is a fair one – I think a relatively easy way out of this would be to put make @mongosh/arg-parser/arg-parser a separate export in package.json instead of including it in its index.ts?
Running into module resolution issues because mongosh has |
We can and should feel free to change our |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
8a0c0c9 to
132a48d
Compare
8530957 to
0d5aeb5
Compare
This moves more of the logic into arg-parser and seperates CLI-repl-specific bits.
There are some further updates I'd apply afterwards in #2589 to make this reusable in MCP but this keeps changes minimal.