Implement CLI options for adding diagrams to config from templates

This commit is contained in:
Bartek Kryza
2023-03-08 01:25:20 +01:00
parent 2092a0e3e6
commit 41537c5401
4 changed files with 180 additions and 57 deletions

View File

@@ -553,12 +553,20 @@ template <> struct convert<diagram_template> {
if (node.Type() == NodeType::Scalar) {
// Check that the template provided as string is at least valid YAML
const auto yaml_node = Load(node.as<std::string>());
const auto diagram_type = yaml_node["type"].as<std::string>();
const auto template_root_it = yaml_node.begin();
const auto diagram_name_template =
template_root_it->first.as<std::string>();
const auto diagram_type =
template_root_it->second["type"].as<std::string>();
rhs.type = clanguml::common::model::from_string(diagram_type);
rhs.jinja_template = Dump(yaml_node);
}
else {
const auto diagram_type = node["type"].as<std::string>();
const auto template_root_it = node.begin();
const auto diagram_name_template =
template_root_it->first.as<std::string>();
const auto diagram_type =
template_root_it->second["type"].as<std::string>();
rhs.type = clanguml::common::model::from_string(diagram_type);
rhs.jinja_template = Dump(node);
}