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