Add '--quiet' comand line option to suppress some output

This commit is contained in:
Adon Shapiro
2017-03-24 14:16:10 -04:00
committed by Andrzej Rybczak
parent 5b7ea189ce
commit 7ba2c3534c
4 changed files with 20 additions and 1 deletions

View File

@@ -24,6 +24,7 @@
#include <boost/program_options.hpp>
#include <iomanip>
#include <iostream>
#include <fstream>
#include "bindings.h"
#include "configuration.h"
@@ -88,6 +89,7 @@ bool configure(int argc, char **argv)
("slave-screen,S", po::value<std::string>()->value_name("SCREEN"), "specify the startup slave screen")
("help,?", "show help message")
("version,v", "display version information")
("quiet,q", "suppress logs and excess output")
;
po::variables_map vm;
@@ -95,6 +97,14 @@ bool configure(int argc, char **argv)
{
po::store(po::parse_command_line(argc, argv, options), vm);
// suppress messages from std::clog
if (vm.count("quiet"))
{
std::ofstream null_stream;
null_stream.open("/dev/null");
std::clog.rdbuf(null_stream.rdbuf());
}
if (vm.count("help"))
{
cout << "Usage: " << argv[0] << " [options]...\n" << options << "\n";