Skip to content

命令行接口

🌐 Command-line Interface

用法

🌐 Usage

'oxfmt' ['-c'='PATH'] ['PATH']...

模式选项:

🌐 Mode Options:

  • --init — 使用默认值初始化 .oxfmtrc.json
  • --migrate=SOURCE — 将配置从指定源迁移到 .oxfmtrc.json 可用源:prettier
  • --lsp — 启动语言服务器协议(LSP)服务器
  • --stdin-filepath=PATH — 指定用于推断使用哪个解析器的文件名

输出选项:

🌐 Output Options:

  • --write — 原地格式化和写入文件(默认)
  • --check — 检查文件是否已格式化,同时显示统计信息
  • --list-different — 列出将被更改的文件

配置选项

🌐 Config Options

  • -c, --config=PATH — 配置文件的路径

忽略选项

🌐 Ignore Options

  • --ignore-path=PATH — 忽略文件的路径。可以多次指定。如果未指定,将使用当前目录下的 .gitignore 和 .prettierignore 文件。
  • --with-node-modules — 在 node_modules 目录中格式化代码(默认情况下跳过)

运行时选项

🌐 Runtime Options

  • --no-error-on-unmatched-pattern — 当模式不匹配时不要以错误退出
  • --threads=INT — 使用的线程数量。设置为 1 表示仅使用 1 个 CPU 核心。

可用位置物品:

🌐 Available positional items:

  • PATH — 单个文件、单条路径或路径列表。如果未提供,则使用当前工作目录。Glob 仅支持用于排除模式,如 '!**/fixtures/*.js'

可用选项:

🌐 Available options:

  • -h--help — 打印帮助信息
  • -V--version — 打印版本信息