From eb264e1892c2a1379fa3bcab9aefea219e8e7138 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 8 Sep 2015 10:56:32 +0200 Subject: Rework diagnostics verbosity, add quiet mode/option --- build/options.cxx | 66 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 16 deletions(-) (limited to 'build/options.cxx') diff --git a/build/options.cxx b/build/options.cxx index 3c1e194..b5c2754 100644 --- a/build/options.cxx +++ b/build/options.cxx @@ -172,7 +172,7 @@ namespace cl struct parser { static void - parse (X& x, scanner& s) + parse (X& x, bool& xs, scanner& s) { std::string o (s.next ()); @@ -185,6 +185,8 @@ namespace cl } else throw missing_value (o); + + xs = true; } }; @@ -203,7 +205,7 @@ namespace cl struct parser { static void - parse (std::string& x, scanner& s) + parse (std::string& x, bool& xs, scanner& s) { const char* o (s.next ()); @@ -211,6 +213,8 @@ namespace cl x = s.next (); else throw missing_value (o); + + xs = true; } }; @@ -218,11 +222,13 @@ namespace cl struct parser > { static void - parse (std::vector& c, scanner& s) + parse (std::vector& c, bool& xs, scanner& s) { X x; - parser::parse (x, s); + bool dummy; + parser::parse (x, dummy, s); c.push_back (x); + xs = true; } }; @@ -230,11 +236,13 @@ namespace cl struct parser > { static void - parse (std::set& c, scanner& s) + parse (std::set& c, bool& xs, scanner& s) { X x; - parser::parse (x, s); + bool dummy; + parser::parse (x, dummy, s); c.insert (x); + xs = true; } }; @@ -242,7 +250,7 @@ namespace cl struct parser > { static void - parse (std::map& m, scanner& s) + parse (std::map& m, bool& xs, scanner& s) { std::string o (s.next ()); @@ -293,6 +301,8 @@ namespace cl } else throw missing_value (o); + + xs = true; } }; @@ -302,6 +312,13 @@ namespace cl { parser::parse (x.*M, s); } + + template + void + thunk (X& x, scanner& s) + { + parser::parse (x.*M, x.*S, s); + } } #include @@ -315,7 +332,9 @@ options () : help_ (), version_ (), v_ (), - verbose_ (0) + q_ (), + verbose_ (1), + verbose_specified_ (false) { } @@ -328,7 +347,9 @@ options (int& argc, : help_ (), version_ (), v_ (), - verbose_ (0) + q_ (), + verbose_ (1), + verbose_specified_ (false) { ::cl::argv_scanner s (argc, argv, erase); _parse (s, opt, arg); @@ -344,7 +365,9 @@ options (int start, : help_ (), version_ (), v_ (), - verbose_ (0) + q_ (), + verbose_ (1), + verbose_specified_ (false) { ::cl::argv_scanner s (start, argc, argv, erase); _parse (s, opt, arg); @@ -360,7 +383,9 @@ options (int& argc, : help_ (), version_ (), v_ (), - verbose_ (0) + q_ (), + verbose_ (1), + verbose_specified_ (false) { ::cl::argv_scanner s (argc, argv, erase); _parse (s, opt, arg); @@ -378,7 +403,9 @@ options (int start, : help_ (), version_ (), v_ (), - verbose_ (0) + q_ (), + verbose_ (1), + verbose_specified_ (false) { ::cl::argv_scanner s (start, argc, argv, erase); _parse (s, opt, arg); @@ -392,7 +419,9 @@ options (::cl::scanner& s, : help_ (), version_ (), v_ (), - verbose_ (0) + q_ (), + verbose_ (1), + verbose_specified_ (false) { _parse (s, opt, arg); } @@ -406,8 +435,10 @@ print_usage (::std::ostream& os) os << "-v Print actual commands being executed." << ::std::endl; - os << "--verbose Set the diagnostics verbosity to a level between 0 (disabled)" << ::std::endl - << " and 5 (lots of information)." << ::std::endl; + os << "-q Run quietly, only printing error messages." << ::std::endl; + + os << "--verbose Set the diagnostics verbosity to between 0 (disabled)" << ::std::endl + << " and 6 (lots of information)." << ::std::endl; } typedef @@ -426,8 +457,11 @@ struct _cli_options_map_init &::cl::thunk< options, bool, &options::version_ >; _cli_options_map_["-v"] = &::cl::thunk< options, bool, &options::v_ >; + _cli_options_map_["-q"] = + &::cl::thunk< options, bool, &options::q_ >; _cli_options_map_["--verbose"] = - &::cl::thunk< options, std::uint16_t, &options::verbose_ >; + &::cl::thunk< options, std::uint16_t, &options::verbose_, + &options::verbose_specified_ >; } }; -- cgit v1.1