A YAML Optimiser é uma biblioteca e um conjunto de ferramentas de linha de comando gravadas em C ++. A biblioteca ajuda a otimizar grandes configurações de YAML usando aliases (âncoras), referências e teclas de mesclagem (substituições). Ele aproveita a biblioteca Rapidyaml para a análise e manipulação da YAML.
O projeto visa fornecer uma maneira rápida e conveniente de otimizar grandes configurações da YAML.
Atualmente, a biblioteca suporta apenas otimizar nós 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 : truePortanto, o resultado seria (observe que as recortes e comentários são removidos no momento):
- 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 A instalação é bastante fácil. Primeiro de tudo, clone o repositório, baixando seus submódulos recursivamente:
git clone https://github.com/Mr-S-Mirzoev/yaml-optimize.git --recursiveSe você deseja testar apenas os recursos do repo, pode ser uma boa idéia clone apenas o topo do repositório:
git clone https://github.com/Mr-S-Mirzoev/yaml-optimize.git --recursive --depth=1Em seguida, no diretório repositório, gerar o projeto com cmake:
cmake -B build -DYO_BUILD_TOOLS=1 -DYO_BUILD_TESTS=1 -DCMAKE_BUILD_TYPE=ReleaseAqui você vê os sinalizadores que podem ser usados ao criar a biblioteca Yaml-Otimize. Yo_build_tools e yo_build_tests são 0 por padrão, pois eu quero que a construção seja mínima. Se você marcar a opção YO_BUILD_TOOLS, as ferramentas Yaml-Otimize e a resolução YAML serão construídas:
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
Agora, podemos construir o projeto:
cmake --build build -j8 --config Debug