Check that output directory exists
This commit is contained in:
@@ -16,4 +16,4 @@ diagrams:
|
|||||||
package_model_class:
|
package_model_class:
|
||||||
include!: uml/package_model_class_diagram.yml
|
include!: uml/package_model_class_diagram.yml
|
||||||
diagram_model_class:
|
diagram_model_class:
|
||||||
include!: uml/diagram_model_class_diagram.yml
|
include!: uml/diagram_model_class_diagram.yml
|
||||||
|
|||||||
25
src/main.cc
25
src/main.cc
@@ -42,6 +42,8 @@ using cx::compilation_database;
|
|||||||
|
|
||||||
void print_diagrams_list(const clanguml::config::config &cfg);
|
void print_diagrams_list(const clanguml::config::config &cfg);
|
||||||
|
|
||||||
|
bool check_output_directory(const std::string &dir);
|
||||||
|
|
||||||
int main(int argc, const char *argv[])
|
int main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
CLI::App app{"Clang-based PlantUML diagram generator for C++"};
|
CLI::App app{"Clang-based PlantUML diagram generator for C++"};
|
||||||
@@ -97,6 +99,9 @@ int main(int argc, const char *argv[])
|
|||||||
if (output_directory)
|
if (output_directory)
|
||||||
od = output_directory.value();
|
od = output_directory.value();
|
||||||
|
|
||||||
|
if (!check_output_directory(od))
|
||||||
|
return 1;
|
||||||
|
|
||||||
for (const auto &[name, diagram] : config.diagrams) {
|
for (const auto &[name, diagram] : config.diagrams) {
|
||||||
// If there are any specific diagram names provided on the command line,
|
// If there are any specific diagram names provided on the command line,
|
||||||
// and this diagram is not in that list - skip it
|
// and this diagram is not in that list - skip it
|
||||||
@@ -164,6 +169,26 @@ int main(int argc, const char *argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool check_output_directory(const std::string &dir)
|
||||||
|
{
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
using std::cout;
|
||||||
|
|
||||||
|
fs::path output_dir{dir};
|
||||||
|
|
||||||
|
if (!fs::exists(output_dir)) {
|
||||||
|
cout << "ERROR: Output directory " << dir << " doesn't exist...\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fs::is_directory(output_dir)) {
|
||||||
|
cout << "ERROR: " << dir << " is not a directory...\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void print_diagrams_list(const clanguml::config::config &cfg)
|
void print_diagrams_list(const clanguml::config::config &cfg)
|
||||||
{
|
{
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
|||||||
Reference in New Issue
Block a user