Added option --print-start-from to list all possible 'start_from' values (fixes #94)
This commit is contained in:
@@ -129,6 +129,8 @@ cli_flow_t cli_handler::parse(int argc, const char **argv)
|
||||
"instead of actual location of `.clang-uml` file.");
|
||||
app.add_flag("--no-metadata", no_metadata,
|
||||
"Skip metadata (e.g. clang-uml version) from diagrams");
|
||||
app.add_flag("--print-start-from", print_start_from,
|
||||
"Print all possible 'start_from' values for a given diagram");
|
||||
|
||||
try {
|
||||
app.parse(argc, argv);
|
||||
@@ -143,7 +145,7 @@ cli_flow_t cli_handler::parse(int argc, const char **argv)
|
||||
exit(app.exit(e)); // NOLINT(concurrency-mt-unsafe)
|
||||
}
|
||||
|
||||
if (quiet || dump_config)
|
||||
if (quiet || dump_config || print_start_from)
|
||||
verbose = 0;
|
||||
else
|
||||
verbose++;
|
||||
@@ -196,6 +198,16 @@ cli_flow_t cli_handler::handle_pre_config_options()
|
||||
return cli_flow_t::kError;
|
||||
}
|
||||
|
||||
if (print_start_from) {
|
||||
if (diagram_names.size() != 1) {
|
||||
LOG_ERROR(
|
||||
"ERROR: '--print-start-from' requires specifying one diagram "
|
||||
"name using '-n' option");
|
||||
|
||||
return cli_flow_t::kError;
|
||||
}
|
||||
}
|
||||
|
||||
if (initialize) {
|
||||
return create_config_file();
|
||||
}
|
||||
@@ -319,6 +331,18 @@ cli_flow_t cli_handler::handle_post_config_options()
|
||||
return cli_flow_t::kContinue;
|
||||
}
|
||||
|
||||
runtime_config cli_handler::get_runtime_config() const
|
||||
{
|
||||
runtime_config cfg;
|
||||
cfg.generators = generators;
|
||||
cfg.verbose = verbose;
|
||||
cfg.print_start_from = print_start_from;
|
||||
cfg.progress = progress;
|
||||
cfg.thread_count = thread_count;
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
cli_flow_t cli_handler::print_version()
|
||||
{
|
||||
ostr_ << "clang-uml " << clanguml::version::CLANG_UML_VERSION << std::endl;
|
||||
@@ -546,8 +570,8 @@ cli_flow_t cli_handler::add_config_diagram_from_template(
|
||||
return cli_flow_t::kError;
|
||||
}
|
||||
|
||||
// First, try to render the template using inja and create a YAML node from
|
||||
// it
|
||||
// First, try to render the template using inja and create a YAML node
|
||||
// from it
|
||||
inja::json ctx;
|
||||
for (const auto &tv : template_variables) {
|
||||
const auto var = util::split(tv, "=");
|
||||
|
||||
@@ -25,6 +25,19 @@
|
||||
#include <optional>
|
||||
|
||||
namespace clanguml::cli {
|
||||
|
||||
/**
|
||||
* @brief This class holds command line parameters not directly related to
|
||||
* specific diagram configurations.
|
||||
*/
|
||||
struct runtime_config {
|
||||
int verbose{};
|
||||
std::vector<clanguml::common::generator_type_t> generators{};
|
||||
bool print_start_from{};
|
||||
bool progress{};
|
||||
unsigned int thread_count{};
|
||||
};
|
||||
|
||||
/**
|
||||
* This enum represents possible exit states of the command line parser.
|
||||
*/
|
||||
@@ -132,6 +145,13 @@ public:
|
||||
*/
|
||||
bool ensure_output_directory_exists(const std::string &dir);
|
||||
|
||||
/**
|
||||
* @brief Combines runtime configuration parameters into a single structure
|
||||
*
|
||||
* @return Runtime config instance
|
||||
*/
|
||||
runtime_config get_runtime_config() const;
|
||||
|
||||
std::string config_path{".clang-uml"};
|
||||
std::optional<std::string> compilation_database_dir{};
|
||||
std::vector<std::string> diagram_names{};
|
||||
@@ -155,6 +175,7 @@ public:
|
||||
std::optional<std::string> add_include_diagram;
|
||||
std::optional<std::string> add_diagram_from_template;
|
||||
bool dump_config{false};
|
||||
bool print_start_from{false};
|
||||
std::optional<bool> paths_relative_to_pwd{};
|
||||
std::vector<std::string> template_variables{};
|
||||
bool list_templates{false};
|
||||
|
||||
Reference in New Issue
Block a user