dragoonboots / yamlformatter
使用refs自动格式化YAML文件
此包的规范存储库似乎已消失,因此包已被冻结。
v0.1.1
2021-02-12 16:07 UTC
Requires
- php: ^7.3|^8.0
- ext-json: *
- opis/json-schema: ^1.0
- php-ds/php-ds: ^1.3
- symfony/console: ^5.0
- symfony/finder: ^5.0
- symfony/yaml: ^5.0
Requires (Dev)
- mikey179/vfsstream: ^1.6
- phpunit/phpunit: ^9.5
Suggests
- ext-ds: Allows a small speed/efficiency increase
This package is auto-updated.
Last update: 2022-11-12 20:34:28 UTC
README
美化您的YAML文件!
功能
- 自动添加重复数据的锚/别名
- 删除不必要的空白字符
- 正确缩进
用法
使用Composer安装
composer require dragoonboots/yamlformatter
使用vendor/bin/yamlformatter format --help
查看可用选项
Usage:
format [options] [--] <INPUT> [<OUTPUT>]
Arguments:
INPUT Input file or directory
OUTPUT Output file or directory. Will overwrite when not specified.
Options:
-o, --override Override .yamlformatter.json options
--indent=INDENT Number of spaces to indent [default: 2]
--no-multiline-literal Write string literals with multiple lines with embedded escaped newlines instead of as a multi-line literal
--no-null-tilde Write null values as "null"
--no-anchors Do not create reference anchors
--anchors-include=ANCHORS-INCLUDE Regular expression for YAML path to generate anchors for. Keys are separated by periods. Defaults to generating anchors for everything. (multiple values allowed)
--anchors-exclude=ANCHORS-EXCLUDE Regular expression for YAML path to not generate anchors for. (multiple values allowed)
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
例如
给定名为resources/data
的目录,这将向所有文件添加refs
vendor/bin/yamlformatter format resources/data
不自动生成refs
vendor/bin/yamlformatter format --no-anchors resources/data
使用不同的输出目录 resources/cleaned
vendor/bin/yamlformatter format resources/data resources/cleaned
选项
如果输入目录中存在名为.yamlformatter.json
的文件,它将被用于设置选项。在该文件中设置的任何选项将覆盖通过命令行传递的选项,除非使用--override
!
该文件包含一个具有以下属性的JSON对象。这些属性的功能与命令行开关相同,尽管其中一些属性被否定
- 缩进
- 多行文本
- 空值作为波浪号
- 锚点
- 包含
- 排除
以下是一个示例
{
"indentation": 2,
"multiLineLiteral": true,
"nullAsTilde": true,
"anchors": {
"exclude": [
"`.+\\.short_effect`"
]
}
}
如果您使用像PHPStorm这样的支持JSON Schema的编辑器,这里提供了一个验证方案 在这里。
许可证
根据MIT许可证授权。