From 73fd1a275b7ed039ef3ca18a3706692e9e95177a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 25 Oct 2019 09:38:40 +0200 Subject: Add --silent, remap verbosity 0 to 1 while building modules unless silent Failed that, we may have long periods of seemingly nothing happening (e.g., during implicit bdep sync) while we quietly update the module, which may look like things have hung up. --- build2/b-options.cxx | 31 ++++++++++++++++++++++++------- build2/b-options.hxx | 4 ++++ build2/b-options.ixx | 6 ++++++ build2/b.cli | 20 ++++++++++++++------ build2/b.cxx | 14 +++++++++++--- 5 files changed, 59 insertions(+), 16 deletions(-) (limited to 'build2') diff --git a/build2/b-options.cxx b/build2/b-options.cxx index 878eb25..dc6b939 100644 --- a/build2/b-options.cxx +++ b/build2/b-options.cxx @@ -650,6 +650,7 @@ namespace build2 : v_ (), V_ (), quiet_ (), + silent_ (), verbose_ (1), verbose_specified_ (false), stat_ (), @@ -777,6 +778,12 @@ namespace build2 this->quiet_, a.quiet_); } + if (a.silent_) + { + ::build2::cl::parser< bool>::merge ( + this->silent_, a.silent_); + } + if (a.verbose_specified_) { ::build2::cl::parser< uint16_t>::merge ( @@ -957,20 +964,28 @@ namespace build2 os << "\033[1mOPTIONS\033[0m" << ::std::endl; os << std::endl - << "\033[1m-v\033[0m Print actual commands being executed. This is equivalent" << ::std::endl - << " to \033[1m--verbose 2\033[0m." << ::std::endl; + << "\033[1m-v\033[0m Print actual commands being executed. This options is" << ::std::endl + << " equivalent to \033[1m--verbose 2\033[0m." << ::std::endl; + + os << std::endl + << "\033[1m-V\033[0m Print all underlying commands being executed. This" << ::std::endl + << " options is equivalent to \033[1m--verbose 3\033[0m." << ::std::endl; os << std::endl - << "\033[1m-V\033[0m Print all underlying commands being executed. This is" << ::std::endl - << " equivalent to \033[1m--verbose 3\033[0m." << ::std::endl; + << "\033[1m--quiet\033[0m|\033[1m-q\033[0m Run quietly, only printing error messages in most" << ::std::endl + << " contexts. In certain contexts (for example, while" << ::std::endl + << " updating build system modules) this verbosity level may" << ::std::endl + << " be ignored. Use --silent\033[0m to run quietly in all contexts." << ::std::endl + << " This option is equivalent to \033[1m--verbose 0\033[0m." << ::std::endl; os << std::endl - << "\033[1m--quiet\033[0m|\033[1m-q\033[0m Run quietly, only printing error messages. This is" << ::std::endl - << " equivalent to \033[1m--verbose 0\033[0m." << ::std::endl; + << "\033[1m--silent\033[0m Run quietly, only printing error messages in all" << ::std::endl + << " contexts." << ::std::endl; os << std::endl << "\033[1m--verbose\033[0m \033[4mlevel\033[0m Set the diagnostics verbosity to \033[4mlevel\033[0m between 0 and 6." << ::std::endl - << " Level 0 disables any non-error messages while level 6" << ::std::endl + << " Level 0 disables any non-error messages (but see the" << ::std::endl + << " difference between --quiet\033[0m and --silent\033[0m) while level 6" << ::std::endl << " produces lots of information, with level 1 being the" << ::std::endl << " default. The following additional types of diagnostics" << ::std::endl << " are produced at each level:" << ::std::endl @@ -1168,6 +1183,8 @@ namespace build2 &::build2::cl::thunk< options, bool, &options::quiet_ >; _cli_options_map_["-q"] = &::build2::cl::thunk< options, bool, &options::quiet_ >; + _cli_options_map_["--silent"] = + &::build2::cl::thunk< options, bool, &options::silent_ >; _cli_options_map_["--verbose"] = &::build2::cl::thunk< options, uint16_t, &options::verbose_, &options::verbose_specified_ >; diff --git a/build2/b-options.hxx b/build2/b-options.hxx index 8fea395..4b1852b 100644 --- a/build2/b-options.hxx +++ b/build2/b-options.hxx @@ -439,6 +439,9 @@ namespace build2 const bool& quiet () const; + const bool& + silent () const; + const uint16_t& verbose () const; @@ -575,6 +578,7 @@ namespace build2 bool v_; bool V_; bool quiet_; + bool silent_; uint16_t verbose_; bool verbose_specified_; bool stat_; diff --git a/build2/b-options.ixx b/build2/b-options.ixx index 3433d79..b8d7198 100644 --- a/build2/b-options.ixx +++ b/build2/b-options.ixx @@ -278,6 +278,12 @@ namespace build2 return this->quiet_; } + inline const bool& options:: + silent () const + { + return this->silent_; + } + inline const uint16_t& options:: verbose () const { diff --git a/build2/b.cli b/build2/b.cli index bf3bf4d..dff707f 100644 --- a/build2/b.cli +++ b/build2/b.cli @@ -391,27 +391,35 @@ namespace build2 bool -v { - "Print actual commands being executed. This is equivalent to + "Print actual commands being executed. This options is equivalent to \cb{--verbose 2}." } bool -V { - "Print all underlying commands being executed. This is equivalent to - \cb{--verbose 3}." + "Print all underlying commands being executed. This options is + equivalent to \cb{--verbose 3}." } bool --quiet|-q { - "Run quietly, only printing error messages. This is equivalent to - \cb{--verbose 0}." + "Run quietly, only printing error messages in most contexts. In certain + contexts (for example, while updating build system modules) this + verbosity level may be ignored. Use \c{--silent} to run quietly in all + contexts. This option is equivalent to \cb{--verbose 0}." + } + + bool --silent + { + "Run quietly, only printing error messages in all contexts." } uint16_t --verbose = 1 { "", "Set the diagnostics verbosity to between 0 and 6. Level 0 - disables any non-error messages while level 6 produces lots of + disables any non-error messages (but see the difference between + \c{--quiet} and \c{--silent}) while level 6 produces lots of information, with level 1 being the default. The following additional types of diagnostics are produced at each level: diff --git a/build2/b.cxx b/build2/b.cxx index e093641..4571567 100644 --- a/build2/b.cxx +++ b/build2/b.cxx @@ -237,9 +237,16 @@ main (int argc, char* argv[]) // auto verbosity = [] () { - return ops.verbose_specified () - ? ops.verbose () - : ops.V () ? 3 : ops.v () ? 2 : ops.quiet () ? 0 : 1; + uint16_t v ( + ops.verbose_specified () + ? ops.verbose () + : ops.V () ? 3 : ops.v () ? 2 : ops.quiet () || ops.silent () ? 0 : 1); + + if (ops.silent () && v != 0) + fail << "specified with -v, -V, or --verbose verbosity level " << v + << " is incompatible with --silent"; + + return v; }; // We want to be able to specify options, vars, and buildspecs in any @@ -423,6 +430,7 @@ main (int argc, char* argv[]) // Initialize the diagnostics state. // init_diag (verbosity (), + ops.silent (), (ops.progress () ? optional (true) : ops.no_progress () ? optional (false) : nullopt), ops.no_line (), -- cgit v1.1