Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Convert "version" option to flag "-V,--version". #34

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions tools/app_version.hpp

This file was deleted.

20 changes: 15 additions & 5 deletions tools/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,22 @@
#include "CLI11.hpp"

#include "add_to.hpp"
#include "app_version.hpp"
#include "build.hpp"
#include "init.hpp"
#include "populate.hpp"
#include "remove_from.hpp"
#include "update.hpp"
#include "validate.hpp"

#include <antler/system/version.hpp>


template <typename T, typename V>
static V depends(V&& v) { return std::forward<V>(v); }

template <typename... Ts>
struct runner {
runner(CLI::App& app)
runner(CLI::App& app)
: tup(depends<Ts>(app)...) {}

template <std::size_t I=0>
Expand All @@ -45,14 +47,22 @@ struct runner {
};

int main(int argc, char** argv) {
// using this as we will alias antler-proj to cdt-proj for the
// using this as we will alias antler-proj to cdt-proj for the
// next release of CDT.
const auto app_name = antler::system::fs::path(argv[0]).filename().string();

CLI::App app{"Antelope Smart Contract Project Management Tool", app_name};

runner<antler::add_to_project,
antler::app_version,
// Add version flag with callback here.
app.add_flag_callback("-V,--version",
[&app]() {
std::cout << app.get_name() << " v" << antler::system::version::full() << std::endl;
std::exit(0); // Succesfull exit MUST happen here.
},
"get the version of antler-proj");


runner<antler::add_to_project,
antler::build_project,
antler::init_project,
antler::populate_project,
Expand Down