|
|
@@ -41,6 +41,12 @@ public:
|
|
|
cli & register_callback(std::string const & handle, F && cb) {
|
|
|
return register_callback(handle, lambdas::FFL(cb));
|
|
|
}
|
|
|
+ template <typename T>
|
|
|
+ cli & register_query(std::string const & handle, std::function<T()> cb);
|
|
|
+ template <typename F>
|
|
|
+ cli & register_query(std::string const & handle, F && cb) {
|
|
|
+ return register_query(handle, lambdas::FFL(cb));
|
|
|
+ }
|
|
|
|
|
|
void run() const;
|
|
|
template <typename T, size_t I>
|
|
|
@@ -77,4 +83,16 @@ cli & cli::register_callback(std::string const & handle,
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
+template <typename T> void cli_print(T const & value) { std::cout << value; }
|
|
|
+
|
|
|
+template <typename T>
|
|
|
+cli & cli::register_query(std::string const & handle, std::function<T()> cb) {
|
|
|
+ arguments_.emplace(handle, 0);
|
|
|
+ callbacks_.emplace(handle, [=](args_t const & args) {
|
|
|
+ using ::cli::cli_print;
|
|
|
+ cli_print(cb());
|
|
|
+ });
|
|
|
+ return *this;
|
|
|
+}
|
|
|
+
|
|
|
}
|