For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt, and this page is available as Markdown at /zh/guide/cli/fmt.md.
  • 简体中文
  • fmt

    rs fmt 命令用于格式化文件或检查文件格式。详细用法请参考格式化指南。

    用法

    rs fmt [options] [files/globs...]

    可以传入文件、目录或 glob 模式来指定格式化范围。不传入路径时,rs fmt 会格式化当前目录。

    示例:

    # 格式化当前目录中的文件
    rs fmt
    
    # 格式化指定文件和目录
    rs fmt src package.json
    
    # 在 CI 中检查格式
    rs fmt --check

    rs formatrs fmt 的别名:

    rs format

    选项

    选项说明
    --write将格式化结果写回文件。这是默认模式。
    --check检查格式但不写入文件;存在格式差异时以状态码 1 退出。
    --list-different仅输出未格式化的路径;存在格式差异时以状态码 1 退出。
    --parallel-workers <count>设置格式化 worker 的最大数量。
    -h, --help显示命令用法和选项。

    --write--check--list-different 不能同时使用。