Added automatic executable version updates
This commit is contained in:
20
src/main.cc
20
src/main.cc
@@ -21,8 +21,8 @@
|
||||
#include "include_diagram/generators/plantuml/include_diagram_generator.h"
|
||||
#include "package_diagram/generators/plantuml/package_diagram_generator.h"
|
||||
#include "sequence_diagram/generators/plantuml/sequence_diagram_generator.h"
|
||||
|
||||
#include "util/util.h"
|
||||
#include "version.h"
|
||||
|
||||
#include <cli11/CLI11.hpp>
|
||||
#include <cppast/libclang_parser.hpp>
|
||||
@@ -38,6 +38,8 @@
|
||||
using namespace clanguml;
|
||||
using config::config;
|
||||
|
||||
void print_version();
|
||||
|
||||
void print_diagrams_list(const clanguml::config::config &cfg);
|
||||
|
||||
bool check_output_directory(const std::string &dir);
|
||||
@@ -55,6 +57,7 @@ int main(int argc, const char *argv[])
|
||||
std::vector<std::string> diagram_names{};
|
||||
std::optional<std::string> output_directory;
|
||||
unsigned int thread_count{0};
|
||||
bool show_version{false};
|
||||
bool verbose{false};
|
||||
bool list_diagrams{false};
|
||||
|
||||
@@ -68,12 +71,18 @@ int main(int argc, const char *argv[])
|
||||
"Override output directory specified in config file");
|
||||
app.add_option("-t,--thread-count", thread_count,
|
||||
"Thread pool size (0 = hardware concurrency)");
|
||||
app.add_flag("-V,--version", show_version, "Print version and exit");
|
||||
app.add_flag("-v,--verbose", verbose, "Verbose logging");
|
||||
app.add_flag("-l,--list-diagrams", list_diagrams,
|
||||
"Print list of diagrams defined in the config file");
|
||||
|
||||
CLI11_PARSE(app, argc, argv);
|
||||
|
||||
if (show_version) {
|
||||
print_version();
|
||||
return 0;
|
||||
}
|
||||
|
||||
clanguml::util::setup_logging(verbose);
|
||||
|
||||
clanguml::config::config config;
|
||||
@@ -223,6 +232,15 @@ bool check_output_directory(const std::string &dir)
|
||||
return true;
|
||||
}
|
||||
|
||||
void print_version()
|
||||
{
|
||||
std::cout << "clang-uml " << clanguml::version::CLANG_UML_VERSION << '\n';
|
||||
std::cout << "Copyright (C) 2021-2022 Bartek Kryza <bkryza@gmail.com>"
|
||||
<< '\n';
|
||||
std::cout << "Built with libclang: "
|
||||
<< clanguml::version::CLANG_UML_LIBCLANG_VERSION << std::endl;
|
||||
}
|
||||
|
||||
void print_diagrams_list(const clanguml::config::config &cfg)
|
||||
{
|
||||
using std::cout;
|
||||
|
||||
23
src/version.h.in
Normal file
23
src/version.h.in
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* src/version.h
|
||||
*
|
||||
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace clanguml::version {
|
||||
static constexpr auto CLANG_UML_VERSION = "@GIT_VERSION@";
|
||||
static constexpr auto CLANG_UML_LIBCLANG_VERSION = "@LIBCLANG_VERSION_STRING@";
|
||||
} // namespace clanguml::version
|
||||
Reference in New Issue
Block a user