YAML Optimierer ist eine Bibliothek und eine Reihe von Befehlszeilen-Tools, die in C ++ geschrieben wurden. Die Bibliothek hilft bei der Optimierung großer YAML -Konfigurationen mithilfe von Aliase (Anker), Referenzen und Zusammenführungsschlüssel (Überschreibungen). Es nutzt die Rapidyaml -Bibliothek für Yaml -Parsen und -manipulation.
Das Projekt zielt darauf ab, eine schnelle und bequeme Möglichkeit zur Optimierung großer YAML -Konfigurationen zu bieten.
Derzeit unterstützt die Bibliothek nur die Optimierung vollständig identischer Knoten:
# 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 : trueDas Ergebnis wäre also (beachten Sie, dass die Einladungen und Kommentare derzeit entfernt werden):
- 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 Die Installation ist ziemlich einfach. Zunächst klonen Sie das Repo und laden Sie die Submodules rekursiv herunter:
git clone https://github.com/Mr-S-Mirzoev/yaml-optimize.git --recursiveWenn Sie nur die Repo -Funktionen testen möchten, ist es möglicherweise eine gute Idee, nur die Spitze des Repo zu klonen:
git clone https://github.com/Mr-S-Mirzoev/yaml-optimize.git --recursive --depth=1Generieren Sie das Projekt als nächstes im Repo -Verzeichnis mit CMake:
cmake -B build -DYO_BUILD_TOOLS=1 -DYO_BUILD_TESTS=1 -DCMAKE_BUILD_TYPE=ReleaseHier sehen Sie die Flags, die beim Erstellen der Yaml-optimizen Bibliothek verwendet werden können. Yo_build_tools und yo_build_tests sind standardmäßig 0, da ich möchte, dass der Build minimal ist. Wenn Sie die Option yo_build_tools ankreuzen, werden Tools Yaml-optimize und Yaml-Resolve erstellt:
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
Jetzt können wir das Projekt erstellen:
cmake --build build -j8 --config Debug