Added add_compile_flag and remove_compile_flag options to cli_handler (#130)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# CHANGELOG
|
||||
|
||||
* Fixed add_compile_flags and added remove_compile_flags config options (#130)
|
||||
* Added rendering of template specialization fields and methods (#128)
|
||||
* Improved template specialization/instantiation matching based on deduced
|
||||
context
|
||||
|
||||
@@ -83,6 +83,11 @@ cli_flow_t cli_handler::parse(int argc, const char **argv)
|
||||
app.add_flag("-l,--list-diagrams", list_diagrams,
|
||||
"Print list of diagrams defined in the config file");
|
||||
app.add_flag("--init", initialize, "Initialize example config file");
|
||||
app.add_option("--add-compile-flag", add_compile_flag,
|
||||
"Add a compilation flag to each entry in the compilation database");
|
||||
app.add_option("--remove-compile-flag", remove_compile_flag,
|
||||
"Remove a compilation flag from each entry in the compilation "
|
||||
"database");
|
||||
app.add_option(
|
||||
"--add-class-diagram", add_class_diagram, "Add class diagram config");
|
||||
app.add_option("--add-sequence-diagram", add_sequence_diagram,
|
||||
@@ -269,6 +274,21 @@ cli_flow_t cli_handler::handle_post_config_options()
|
||||
if (!ensure_output_directory_exists(effective_output_directory))
|
||||
return cli_flow_t::kError;
|
||||
|
||||
//
|
||||
// Append add_compile_flags and remove_compile_flags to the config
|
||||
//
|
||||
if (add_compile_flag) {
|
||||
std::copy(add_compile_flag->begin(), add_compile_flag->end(),
|
||||
std::back_inserter(config.add_compile_flags.value));
|
||||
config.add_compile_flags.has_value = true;
|
||||
}
|
||||
|
||||
if (remove_compile_flag) {
|
||||
std::copy(remove_compile_flag->begin(), remove_compile_flag->end(),
|
||||
std::back_inserter(config.remove_compile_flags.value));
|
||||
config.remove_compile_flags.has_value = true;
|
||||
}
|
||||
|
||||
return cli_flow_t::kContinue;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,6 +121,8 @@ public:
|
||||
bool list_diagrams{false};
|
||||
bool quiet{false};
|
||||
bool initialize{false};
|
||||
std::optional<std::vector<std::string>> add_compile_flag;
|
||||
std::optional<std::vector<std::string>> remove_compile_flag;
|
||||
std::optional<std::string> add_class_diagram;
|
||||
std::optional<std::string> add_sequence_diagram;
|
||||
std::optional<std::string> add_package_diagram;
|
||||
|
||||
@@ -156,4 +156,31 @@ TEST_CASE("Test cli handler print_diagram_template", "[unit-test]")
|
||||
namespaces: [{{ namespace_name }}]
|
||||
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
"Test cli handler add_compile_flag and remove_compile_flag", "[unit-test]")
|
||||
{
|
||||
using clanguml::cli::cli_flow_t;
|
||||
using clanguml::cli::cli_handler;
|
||||
using clanguml::util::contains;
|
||||
|
||||
std::vector<const char *> argv{"clang-uml", "--config",
|
||||
"./test_config_data/simple.yml", "--add-compile-flag", "-Wno-error",
|
||||
"--add-compile-flag", "-Wno-warning", "--remove-compile-flag",
|
||||
"-I/usr/include"};
|
||||
|
||||
std::ostringstream ostr;
|
||||
cli_handler cli{ostr, make_sstream_logger(ostr)};
|
||||
|
||||
auto res = cli.handle_options(argv.size(), argv.data());
|
||||
|
||||
REQUIRE(res == cli_flow_t::kContinue);
|
||||
|
||||
REQUIRE(cli.config.add_compile_flags.has_value);
|
||||
REQUIRE(cli.config.remove_compile_flags.has_value);
|
||||
|
||||
REQUIRE(contains(cli.config.add_compile_flags(), "-Wno-error"));
|
||||
REQUIRE(contains(cli.config.add_compile_flags(), "-Wno-warning"));
|
||||
REQUIRE(contains(cli.config.remove_compile_flags(), "-I/usr/include"));
|
||||
}
|
||||
Reference in New Issue
Block a user