基于ruamel.yaml的固执己见的yaml形成剂
yamkix的Python项目详细描述
为什么?
- 因为我喜欢我的yaml文件格式良好
- 因为 https://marketplace.visualstudio.com/items?itemName=adamvoss.yaml 创建(有效的)与kubernetes不兼容的yaml(我主要编辑 kubernetes的yaml文件)
- 因为 https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml 不添加文档的显式开头,我不喜欢这样
- 因为我不是js/typescript开发人员,所以我不想进入 使用客户机和服务器语言扩展vscode
什么?
> ./yamkix -h usage: yamkix [-h] -i INPUT [-t TYP][-o OUTPUT][-n][-e][-q][-f][-d] Format yaml input file. By default, explicit_start is `On`, explicit_end is `Off` and array elements are pushed inwards the start of the matching sequence. Comments are preserved thanks to default parsing mode `rt`. optional arguments: -h, --help show this help message and exit -i INPUT, --input INPUT the file to parse -t TYP, --typ TYP the yaml parser mode. Can be `safe` or `rt` -o OUTPUT, --output OUTPUT the name of the file to generate (same as input file if not specied) -n, --no-explicit-start by default, explicit start of the yaml doc is `On`, you can disable it with this option -e, --explicit-end by default, explicit end of the yaml doc is `Off`, you can enable it with this option -q, --no-quotes-preserved by default, quotes are preserverd you can disable this with this option -f, --default-flow-style enable the default flow style `Off` by default. In default flow style (with typ=`rt`), maps and lists are written like json -d, --no-dash-inwards by default, dash are pushed inwards use `--no-dash-inwards` to have the dash start at the sequence level
配置
- defaut显式启动yaml文档 (您可以使用--no-explicit-start禁用它)
- 默认保留引号 (您可以使用--no-quotes-preserved禁用它)
- 默认情况下,数组元素向内推 (您可以使用--no-dash-inwards禁用它)
- 默认情况下,输出文件是输入文件
- 默认情况下,由于 ruamel.yamlround_trip 模式(您可以使用--typ safe禁用它)
“Yamkix”这个名字是从哪里来的?
- 多亏了 http://online-generator.com/name-generator/product-name-generator.php 这暗示了我zamkix。刚把开始的z换成 yaml的y
用法
- 使用pip install --user yamkix 安装包
- 示例vscode任务:
{"taskName":"format yaml with yamkix","type":"shell","command":"yamkix --input ${file}","group":"build","presentation":{"reveal":"always","panel":"shared"},"problemMatcher":[]}