Yaml Optimiser es una biblioteca y un conjunto de herramientas de línea de comandos escritas en C ++. La biblioteca ayuda a optimizar grandes configuraciones YAML utilizando alias (anclajes), referencias y fusiones de claves (anulaciones). Aprovecha la biblioteca Rapidyaml para el análisis y la manipulación de Yaml.
El proyecto tiene como objetivo proporcionar una forma rápida y conveniente de optimizar grandes configuraciones YAML.
Actualmente, la biblioteca solo admite la optimización de nodos totalmente idénticos:
# 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 : trueEntonces, el resultado sería (tenga en cuenta que las hendiduras y los comentarios se eliminan actualmente):
- 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 La instalación es bastante fácil. En primer lugar, clona el repositorio, descargando sus submódulos de manera recursiva:
git clone https://github.com/Mr-S-Mirzoev/yaml-optimize.git --recursiveSi solo desea probar las funciones de repositorio, puede ser una buena idea clonar solo la parte superior del repositorio:
git clone https://github.com/Mr-S-Mirzoev/yaml-optimize.git --recursive --depth=1A continuación, en el directorio de repo, genere el proyecto con CMake:
cmake -B build -DYO_BUILD_TOOLS=1 -DYO_BUILD_TESTS=1 -DCMAKE_BUILD_TYPE=ReleaseAquí ves las banderas que se pueden usar al construir la biblioteca YAML-Optimize. Yo_build_tools y yo_build_tests son 0 por defecto, ya que quiero que la compilación sea mínima. Si marca la opción yo_build_tools, se construyen herramientas yaml-optimize y 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
Ahora podemos construir el proyecto:
cmake --build build -j8 --config Debug