carthage-software/mago
Mago is an extremely fast PHP linter, formatter, and static analyzer written in Rust. It helps teams catch issues early, enforce consistent style, and improve code quality across projects, with multiple install options like script, Homebrew, Composer, and Cargo.
+++ title = "列出文件" description = "在当前配置下,精确显示 Mago 将要处理的文件。" nav_order = 60 nav_section = "指南" +++
mago list-files 会按当前配置打印出 Mago 会触及的文件。这是确认 paths、includes 和 excludes 是否如你所想发挥作用的最快方式。
mago list-files
这会打印 [source].paths 中的文件,即你项目自己的源码。includes 中(通常是 vendor)的文件不会显示,因为它们是为提供上下文而被解析的,并不会被分析。
每个工具(linter、格式化器、分析器、guard)都有自己的可选 excludes,会叠加在全局排除之上。因此不同工具处理的文件集不同。要查看某个工具的视角:
mago list-files --command linter
mago list-files --command formatter
mago list-files --command analyzer
mago list-files --command guard
给定如下配置:
[source]
paths = ["src", "tests"]
excludes = ["cache/**"] # 对所有工具排除
[analyzer]
excludes = ["tests/**/*.php"] # 额外对分析器排除
[formatter]
excludes = ["src/**/AutoGenerated/**"] # 额外对格式化器排除
得到的列表会有差异:
mago list-files # src/** + tests/**, 除去 cache/**
mago list-files --command analyzer # 仅 src/** (tests 被排除)
mago list-files --command formatter # src/** + tests/**, 除去 AutoGenerated 文件
文件名中可能包含换行符。如果你打算把输出喂给像 xargs 这样的工具,请改用 NUL 字节作为终止符:
mago list-files -0 | xargs -0r ls -l
Usage: mago list-files [OPTIONS]
| 参数 | 说明 |
|---|---|
--command <COMMAND> |
应用某个工具的排除规则。可选值:linter、formatter、analyzer、guard。 |
-0, --zero-terminate |
用 NUL 而非换行符作为文件名终止符。 |
-h, --help |
打印帮助并退出。 |
全局参数必须放在 list-files 之前。完整列表见 CLI 概览。
How can I help you explore Laravel packages today?