Skip to content

Commit

Permalink
app-template: allow apps to specify a name for help message
Browse files Browse the repository at this point in the history
Right now the help message just say "App options" for the app-specific
options, while naming Core, SMP, Metrics, etc, by name.

It's a nice addition to allow the application to be named as well.

Signed-off-by: Glauber Costa <glauber@scylladb.com>
Message-Id: <1490277033-31971-1-git-send-email-glauber@scylladb.com>
  • Loading branch information
Glauber Costa authored and avikivity committed Mar 23, 2017
1 parent 6b7c5c6 commit f8fa1f3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
19 changes: 10 additions & 9 deletions core/app-template.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@

namespace bpo = boost::program_options;

app_template::app_template()
: _opts("App options") {
_opts.add_options()
("help,h", "show help message")
;
_opts.add(reactor::get_options_description());
_opts.add(seastar::metrics::get_options_description());
_opts.add(smp::get_options_description());
_opts.add(scollectd::get_options_description());
app_template::app_template(app_template::config cfg)
: _cfg(std::move(cfg))
, _opts(_cfg.name + " options") {
_opts.add_options()
("help,h", "show help message")
;
_opts.add(reactor::get_options_description());
_opts.add(seastar::metrics::get_options_description());
_opts.add(smp::get_options_description());
_opts.add(scollectd::get_options_description());
}

boost::program_options::options_description_easy_init
Expand Down
9 changes: 8 additions & 1 deletion core/app-template.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@
#include <boost/optional.hpp>
#include <functional>
#include <core/future.hh>
#include <core/sstring.hh>

class app_template {
public:
struct config {
sstring name;
};
private:
config _cfg;
boost::program_options::options_description _opts;
boost::program_options::positional_options_description _pos_opts;
boost::optional<boost::program_options::variables_map> _configuration;
Expand All @@ -39,7 +45,8 @@ public:
int max_count;
};
public:
app_template();
explicit app_template(config cfg = config{"App"});

boost::program_options::options_description_easy_init add_options();
void add_positional_options(std::initializer_list<positional_option> options);
boost::program_options::variables_map& configuration();
Expand Down

0 comments on commit f8fa1f3

Please sign in to comment.