Skip to content

Commit

Permalink
Add verbose command line option
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Filak committed May 19, 2016
1 parent 0b60d6f commit 070cf46
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion service/report-daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,33 @@ on_signal_quit(gpointer)
}

int
main(void)
main(int argc, char *argv[])
{
Gio::init();

{
bool verbose = false;
Glib::OptionEntry opt_v;
opt_v.set_short_name('v');
opt_v.set_long_name("verbose");
opt_v.set_description("Produce debugging output");

Glib::OptionGroup options{"OPTIONS", "Program options"};
options.add_entry(opt_v, verbose);

Glib::OptionContext context;
context.set_help_enabled();
context.set_main_group(options);

if (!context.parse(argc, argv)) {
errx(EXIT_FAILURE, "Invalid command line arguments");
}

if (verbose) {
Glib::setenv("G_MESSAGES_DEBUG", "all");
}
}

{ /* Test availability of Session bus */
try {
auto connection = Gio::DBus::Connection::get_sync(Gio::DBus::BusType::BUS_TYPE_SESSION);
Expand Down

0 comments on commit 070cf46

Please sign in to comment.