Skip to content

feat(oxfmt): Arrange cli mode and update help#16728

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-11-refactor_oxfmt_arrange_cli_mode_and_help
Dec 11, 2025
Merged

feat(oxfmt): Arrange cli mode and update help#16728
graphite-app[bot] merged 1 commit intomainfrom
12-11-refactor_oxfmt_arrange_cli_mode_and_help

Conversation

@leaysgur
Copy link
Copy Markdown
Member

@leaysgur leaysgur commented Dec 11, 2025

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

Copilot AI review requested due to automatic review settings December 11, 2025 04:44
@github-actions github-actions bot added A-cli Area - CLI A-formatter Area - Formatter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Dec 11, 2025
Copy link
Copy Markdown
Member Author

leaysgur commented Dec 11, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@leaysgur leaysgur force-pushed the 12-11-refactor_oxfmt_arrange_cli_mode_and_help branch from 9e13d67 to 9646fd3 Compare December 11, 2025 04:45
@leaysgur leaysgur changed the title refactor(oxfmt): Arrange cli mode and help feat(oxfmt): Arrange cli mode and update help Dec 11, 2025
@leaysgur leaysgur requested a review from Dunqing December 11, 2025 04:47
@github-actions github-actions bot added the C-enhancement Category - New feature or request label Dec 11, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 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 Mode enum with Init, Lsp, and Cli(CliMode) variants to replace scattered boolean flags
  • Renames and reorganizes option structs: BasicOptionsConfigOptions, MiscOptionsRuntimeOptions, OutputOptionsCliMode
  • 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.

@leaysgur leaysgur marked this pull request as draft December 11, 2025 04:52
@leaysgur leaysgur force-pushed the 12-11-refactor_oxfmt_arrange_cli_mode_and_help branch from 9646fd3 to 98c4ed3 Compare December 11, 2025 04:56
@leaysgur leaysgur marked this pull request as ready for review December 11, 2025 04:56
@leaysgur leaysgur force-pushed the 12-11-refactor_oxfmt_arrange_cli_mode_and_help branch from 98c4ed3 to c9a041a Compare December 11, 2025 05:02
Copy link
Copy Markdown
Member

@Boshen Boshen left a comment

Choose a reason for hiding this comment

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

"Available positional items" should be at the top, otherwise it's hard to find what PATH is.

@leaysgur
Copy link
Copy Markdown
Member Author

leaysgur commented Dec 11, 2025

@leaysgur leaysgur requested a review from Boshen December 11, 2025 07:17
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Dec 11, 2025
Copy link
Copy Markdown
Member

Boshen commented Dec 11, 2025

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

```
@graphite-app graphite-app bot force-pushed the 12-11-refactor_oxfmt_arrange_cli_mode_and_help branch from c9a041a to 47c8710 Compare December 11, 2025 07:59
@graphite-app graphite-app bot merged commit 47c8710 into main Dec 11, 2025
18 checks passed
@graphite-app graphite-app bot deleted the 12-11-refactor_oxfmt_arrange_cli_mode_and_help branch December 11, 2025 08:05
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 11, 2025
@pacak
Copy link
Copy Markdown

pacak commented Dec 12, 2025

"Available positional items" should be at the top, otherwise it's hard to find what PATH is.

@Boshen Unfortunately, this seems bpaf's design. (And current output also the same)
https://github.com/pacak/bpaf/blob/5aef3d7defbcbe5480590ee948133161fe79a02f/src/lib.rs#L1374

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-formatter Area - Formatter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants