feat(oxfmt): Arrange cli mode and update help#16728
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
9e13d67 to
9646fd3
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the oxfmt CLI to better organize command modes and options. The main change consolidates the --init, --lsp, and format operation flags into a unified Mode enum structure, improving code organization and maintainability. Options are also reorganized into more semantically meaningful groups (ConfigOptions, RuntimeOptions).
Key changes:
- Introduces a new
Modeenum withInit,Lsp, andCli(CliMode)variants to replace scattered boolean flags - Renames and reorganizes option structs:
BasicOptions→ConfigOptions,MiscOptions→RuntimeOptions,OutputOptions→CliMode - Updates all usage sites (
main.rs,main_napi.rs,format.rs,service.rs) to use the new mode-based pattern matching
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/oxfmt/src/cli/command.rs | Introduces Mode and CliMode enums with custom parser functions; reorganizes options into ConfigOptions and RuntimeOptions |
| apps/oxfmt/src/cli/mod.rs | Exports new Mode enum alongside format_command |
| apps/oxfmt/src/main.rs | Replaces conditional if checks with match on command.mode |
| apps/oxfmt/src/main_napi.rs | Replaces conditional if checks with match on command.mode |
| apps/oxfmt/src/cli/format.rs | Extracts CliMode from Mode::Cli variant; updates field references to use new option struct names |
| apps/oxfmt/src/cli/service.rs | Renames output_options: OutputOptions to format_mode: CliMode for consistency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9646fd3 to
98c4ed3
Compare
98c4ed3 to
c9a041a
Compare
Boshen
left a comment
There was a problem hiding this comment.
"Available positional items" should be at the top, otherwise it's hard to find what PATH is.
|
@Boshen Unfortunately, this seems |
Merge activity
|
Updated to:
```
Usage: oxfmt [-c=PATH] [PATH]...
Mode Options:
--init Initialize `.oxfmtrc.jsonc` with default values
--lsp Start language server protocol (LSP) server
Output Options:
--write Format and write files in place (default)
--check Check if files are formatted, also show statistics
--list-different List files that would be changed
Config Options
-c, --config=PATH Path to the configuration file
Ignore Options
--ignore-path=PATH Path to ignore file(s). Can be specified multiple times. If not
specified, .gitignore and .prettierignore in the current directory are
used.
--with-node-modules Format code in node_modules directory (skipped by default)
Runtime Options
--no-error-on-unmatched-pattern Do not exit with error when pattern is unmatched
--threads=INT Number of threads to use. Set to 1 for using only 1 CPU core.
Available positional items:
PATH Single file, single path or list of paths. If not provided, current
working directory is used. Glob is supported only for exclude patterns
like `'!**/fixtures/*.js'`.
Available options:
-h, --help Prints help information
-V, --version Prints version information
```
c9a041a to
47c8710
Compare
Link refers to a different problem. In current version positional items must be consumed last (placed at the end of the parser) and changing this is hard without changing the design. Items in the help menu are sorted according to some rules and ability to move positional items higher is not exposed, but not really blocked by the design. Speaking about changing the design. I'm working on a next version that removes some of the restrictions. Still some time away. Are there any features you wanted to have but couldn't achieve with current API? |

Updated to: