Yaml Optimiser عبارة عن مكتبة ومجموعة من أدوات سطر الأوامر المكتوبة في 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بعد ذلك ، في دليل Repo ، قم بإنشاء المشروع باستخدام Cmake:
cmake -B build -DYO_BUILD_TOOLS=1 -DYO_BUILD_TESTS=1 -DCMAKE_BUILD_TYPE=Releaseهنا ترى الأعلام التي يمكن استخدامها عند بناء مكتبة Yaml-Optimize. 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