yaml optimize
1.0.0
YAML优化器是用C ++编写的命令行工具的库。该库有助于使用别名(锚),参考和合并密钥(覆盖)优化大型YAML配置。它利用Rapidyaml库进行YAML解析和操纵。
该项目旨在提供一种快速便捷的方法来优化大型YAML配置。
当前,库仅支持优化完全相同的节点:
# YAML example with references and anchors
# Define an anchor for a nested sequence
- top_level :
- nested :
- - Apple
- Orange
- Banana
# Define an anchor for a nested mapping
- another_level :
- even_deeper :
- further :
- key1 : value1
key2 : value2
# Use the anchors in different parts of the YAML
- other_level :
- some_key :
- Apple
- Orange
- Banana
- additional_key :
key1 : value1
key2 : value2
# Additional data
- SomeList :
- 1
- 2
- 3
- 4
- SomeValue : true因此,结果将是(请注意,缩进和评论当前已被删除):
- top_level :
- nested :
- &anchor_0
- Apple
- Orange
- Banana
- another_level :
- even_deeper :
- further :
- &anchor_1
key1 : value1
key2 : value2
- other_level :
- some_key : *anchor_0
- additional_key : *anchor_1
- SomeList :
- 1
- 2
- 3
- 4
- SomeValue : true 安装非常容易。首先,克隆回购,递归下载其子模型:
git clone https://github.com/Mr-S-Mirzoev/yaml-optimize.git --recursive如果您只想测试回购功能,那么只能克隆回购的顶部可能是一个好主意:
git clone https://github.com/Mr-S-Mirzoev/yaml-optimize.git --recursive --depth=1接下来,在回购目录中,使用cmake生成项目:
cmake -B build -DYO_BUILD_TOOLS=1 -DYO_BUILD_TESTS=1 -DCMAKE_BUILD_TYPE=Release在这里,您会看到构建YAML优化库时可以使用的标志。 yo_build_tools和yo_build_tests默认为0,因为我希望构建最小。如果您打勾YO_BUILD_TOOLS选项,则构建了Yaml-Optimize和Yaml-resolve的工具:
USAGE:
yaml-optimize [-?|-h|--help] [-l|--limit <optimization limit>] -i|--input <input> [-o|--output <output>] [-v|--verbose]
YAML Optimizer - A tool for optimising YAML configurations with the use of anchors, references and merge keys
OPTIONS, ARGUMENTS:
-?, -h, --help
-l, --limit <optimization limit>
limit to when to stop optimisation
-i, --input <input> path to input file
-o, --output <output> path to output file (defaults to input filename + ".optimized")
-v, --verbose enable verbose mode
USAGE:
yaml-resolve [-?|-h|--help] -i|--input <input> [-o|--output <output>] [-v|--verbose]
YAML Resolver - A tool for resolving YAML optimised configurations with anchors, references, and merge keys, substituting them to obtain the complete YAML configuration
OPTIONS, ARGUMENTS:
-?, -h, --help
-i, --input <input> path to input file
-o, --output <output> path to output file (defaults to input filename + ".resolved")
-v, --verbose enable verbose mode
现在,我们可以建立该项目:
cmake --build build -j8 --config Debug