aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-04-30 15:18:41 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-04-30 15:18:41 +0200
commite9b4f854dff90874a9009be8470f6e180fc60865 (patch)
tree7dbd2739774a3041a96c5aafd2f2e8ec94d066ef
parent0eed5982bbca328cc6319d36708d64a285160972 (diff)
Cleanup b and bpkg diagnostics verbosity
-rw-r--r--bdep/config.cxx2
-rw-r--r--bdep/fetch.cxx3
-rw-r--r--bdep/init.cxx3
-rw-r--r--bdep/status.cxx6
-rw-r--r--bdep/sync.cxx8
-rw-r--r--bdep/utility.hxx8
-rw-r--r--bdep/utility.txx79
7 files changed, 67 insertions, 42 deletions
diff --git a/bdep/config.cxx b/bdep/config.cxx
index aeb1a5f..45cba1f 100644
--- a/bdep/config.cxx
+++ b/bdep/config.cxx
@@ -149,7 +149,7 @@ namespace bdep
while (cfg_args.more ())
args.push_back (cfg_args.next ());
- run_bpkg (co, "create", "-d", path, args);
+ run_bpkg (2, co, "create", "-d", path, args);
}
return cmd_config_add (ao,
diff --git a/bdep/fetch.cxx b/bdep/fetch.cxx
index 26a0292..361b11a 100644
--- a/bdep/fetch.cxx
+++ b/bdep/fetch.cxx
@@ -20,7 +20,8 @@ namespace bdep
// Let's use the repository name rather than the location as a sanity
// check (the repository must have been added as part of init).
//
- run_bpkg (o,
+ run_bpkg (2,
+ o,
"fetch",
"-d", c->path,
(full ? nullptr : ("dir:" + prj.string ()).c_str ()));
diff --git a/bdep/init.cxx b/bdep/init.cxx
index f03b7cc..603a567 100644
--- a/bdep/init.cxx
+++ b/bdep/init.cxx
@@ -84,7 +84,8 @@ namespace bdep
// Add project repository to the configuration. Note that we don't fetch
// it since sync is going to do it anyway.
//
- run_bpkg (o,
+ run_bpkg (3,
+ o,
"add",
"-d", c->path,
"--type", "dir",
diff --git a/bdep/status.cxx b/bdep/status.cxx
index 4aa3fe6..2b04f9d 100644
--- a/bdep/status.cxx
+++ b/bdep/status.cxx
@@ -28,7 +28,8 @@ namespace bdep
// We do it in a separate command for the same reason as in sync.
//
if (fetch)
- run_bpkg (o,
+ run_bpkg (3,
+ o,
"fetch",
"-d", cfg,
"--shallow",
@@ -37,7 +38,8 @@ namespace bdep
// Don't show the hold status since the only packages that will normally
// be held are the project's. But do show dependency constraints.
//
- run_bpkg (o,
+ run_bpkg (2,
+ o,
"status",
"-d", cfg,
"--no-hold",
diff --git a/bdep/sync.cxx b/bdep/sync.cxx
index 994d76e..f0821a1 100644
--- a/bdep/sync.cxx
+++ b/bdep/sync.cxx
@@ -48,7 +48,8 @@ namespace bdep
{
fdpipe pipe (fdopen_pipe ()); // Text mode seems appropriate.
- pr = start_bpkg (co,
+ pr = start_bpkg (3,
+ co,
pipe /* stdout */,
2 /* stderr */,
"rep-list",
@@ -247,7 +248,7 @@ namespace bdep
// init'ed packages in this configuration.
//
if (!reps.empty ())
- run_bpkg (co, "fetch", "-d", cfg, "--shallow", reps);
+ run_bpkg (3, co, "fetch", "-d", cfg, "--shallow", reps);
// For implicit sync (normally performed on one configuration at a time)
// add the configuration directory to the plan header.
@@ -260,7 +261,8 @@ namespace bdep
? "synchronizing " + cfg.representation () + ':'
: "synchronizing:");
- run_bpkg (co,
+ run_bpkg (2,
+ co,
"build",
"-d", cfg,
"--no-fetch",
diff --git a/bdep/utility.hxx b/bdep/utility.hxx
index 1ecdc6a..dc9e589 100644
--- a/bdep/utility.hxx
+++ b/bdep/utility.hxx
@@ -121,14 +121,18 @@ namespace bdep
template <typename O, typename E, typename... A>
process
- start_bpkg (const common_options&, O&& out, E&& err, A&&... args);
+ start_bpkg (uint16_t verbosity,
+ const common_options&,
+ O&& out,
+ E&& err,
+ A&&... args);
void
finish_bpkg (const common_options&, process&, bool io_error = false);
template <typename... A>
void
- run_bpkg (const common_options&, A&&... args);
+ run_bpkg (uint16_t verbosity, const common_options&, A&&... args);
// Run the b process.
//
diff --git a/bdep/utility.txx b/bdep/utility.txx
index f09983e..b80388f 100644
--- a/bdep/utility.txx
+++ b/bdep/utility.txx
@@ -59,7 +59,8 @@ namespace bdep
//
template <typename O, typename E, typename... A>
process
- start_bpkg (const common_options& co,
+ start_bpkg (uint16_t v,
+ const common_options& co,
O&& out,
E&& err,
A&&... args)
@@ -72,23 +73,29 @@ namespace bdep
small_vector<const char*, 1> ops;
- // Map verbosity level. If we are running quiet or at level 1, then run
- // bpkg quiet. Otherwise, run it at the same level as us.
+ // Map verbosity level.
//
- bool quiet (false); // Maybe will become an argument one day.
+ bool q (false);
string vl;
- switch (verb)
{
- case 0: ops.push_back ( "-q"); break;
- case 1: ops.push_back (quiet ? "-q" : "--no-result"); break;
- case 2: ops.push_back ( "-v"); break;
- default:
+ const char* o (nullptr);
+
+ switch (verb)
{
- vl = to_string (verb);
- ops.push_back ("--verbose");
- ops.push_back (vl.c_str ());
+ case 0: o = "-q"; break;
+ case 1: o = q ? "-q" : "--no-result"; break;
+ case 2: o = 2 >= v ? "-v" : "--no-result"; break;
+ default:
+ {
+ ops.push_back ("--verbose");
+ vl = to_string (verb);
+ o = vl.c_str ();
+ }
}
+
+ if (o != nullptr)
+ ops.push_back (o);
}
// Forward our --build* options.
@@ -106,9 +113,9 @@ namespace bdep
}
return process_start_callback (
- [] (const char* const args[], size_t n)
+ [v] (const char* const args[], size_t n)
{
- if (verb >= 2)
+ if (verb >= v)
print_process (args, n);
},
0 /* stdin */,
@@ -127,9 +134,10 @@ namespace bdep
template <typename... A>
void
- run_bpkg (const common_options& co, A&&... args)
+ run_bpkg (uint16_t v, const common_options& co, A&&... args)
{
- process pr (start_bpkg (co,
+ process pr (start_bpkg (v,
+ co,
1 /* stdout */,
2 /* stderr */,
forward<A> (args)...));
@@ -141,9 +149,9 @@ namespace bdep
template <typename O, typename E, typename... A>
process
start_b (const common_options& co,
- O&& out,
- E&& err,
- A&&... args)
+ O&& out,
+ E&& err,
+ A&&... args)
{
const char* b (name_b (co));
@@ -153,29 +161,36 @@ namespace bdep
small_vector<const char*, 1> ops;
- // Map verbosity level. If we are running quiet or at level 1, then run
- // b quiet. Otherwise, run it at the same level as us.
+ // Map verbosity level.
//
- bool quiet (true); // Maybe will become an argument one day.
+ bool q (true);
+ uint16_t v (3);
string vl;
- switch (verb)
{
- case 0: ops.push_back ("-q"); break;
- case 1: if (quiet) ops.push_back ("-q"); break;
- case 2: ops.push_back ("-v"); break;
- default:
+ const char* o (nullptr);
+
+ switch (verb)
{
- vl = to_string (verb);
- ops.push_back ("--verbose");
- ops.push_back (vl.c_str ());
+ case 0: o = "-q"; break;
+ case 1: o = q ? "-q" : nullptr; break;
+ case 2: o = 2 >= v ? "-v" : q ? "-q" : nullptr; break;
+ default:
+ {
+ ops.push_back ("--verbose");
+ vl = to_string (verb);
+ o = vl.c_str ();
+ }
}
+
+ if (o != nullptr)
+ ops.push_back (o);
}
return process_start_callback (
- [] (const char* const args[], size_t n)
+ [v] (const char* const args[], size_t n)
{
- if (verb >= 2)
+ if (verb >= v)
print_process (args, n);
},
0 /* stdin */,