aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bdep/bdep.cxx41
-rw-r--r--bdep/ci.cxx2
-rw-r--r--bdep/common.cli24
-rw-r--r--bdep/git.txx2
-rw-r--r--bdep/http-service.cxx15
-rw-r--r--bdep/publish.cxx4
-rw-r--r--bdep/release.cxx2
-rw-r--r--bdep/utility.txx18
8 files changed, 80 insertions, 28 deletions
diff --git a/bdep/bdep.cxx b/bdep/bdep.cxx
index dd65c25..9731aaa 100644
--- a/bdep/bdep.cxx
+++ b/bdep/bdep.cxx
@@ -259,7 +259,7 @@ init (const common_options& co,
if (o.default_options_specified ())
extra = o.default_options ();
- o = merge_options (
+ default_options<O> dos (
load_default_options<O, cli::argv_file_scanner, cli::unknown_mode> (
nullopt /* sys_dir */,
home_directory (),
@@ -277,8 +277,43 @@ init (const common_options& co,
},
"--options-file",
args_pos,
- 1024),
- o);
+ 1024));
+
+ // Verify common options.
+ //
+ // Also merge the --progress/--no-progress options, overriding a less
+ // specific flag with a more specific.
+ //
+ optional<bool> progress;
+ auto merge_progress = [&progress]
+ (const O& o,
+ const default_options_entry<O>* e = nullptr)
+ {
+ if (o.progress () && o.no_progress ())
+ {
+ diag_record dr;
+ (e != nullptr ? dr << fail (e->file) : dr << fail)
+ << "both --progress and --no-progress specified";
+ }
+
+ if (o.progress ())
+ progress = true;
+ else if (o.no_progress ())
+ progress = false;
+ };
+
+ for (const default_options_entry<O>& e: dos)
+ merge_progress (e.options, &e);
+
+ merge_progress (o);
+
+ o = merge_options (dos, o);
+
+ if (progress)
+ {
+ o.progress (*progress);
+ o.no_progress (!*progress);
+ }
}
catch (const invalid_argument& e)
{
diff --git a/bdep/ci.cxx b/bdep/ci.cxx
index 1182108..216c598 100644
--- a/bdep/ci.cxx
+++ b/bdep/ci.cxx
@@ -457,7 +457,7 @@ namespace bdep
{
// Print progress unless we had a prompt.
//
- if (verb && o.yes () && !o.no_progress ())
+ if (o.yes () && ((verb && !o.no_progress ()) || o.progress ()))
text << "submitting to " << srv;
url u (srv);
diff --git a/bdep/common.cli b/bdep/common.cli
index cff5790..cdf0e2c 100644
--- a/bdep/common.cli
+++ b/bdep/common.cli
@@ -91,15 +91,23 @@ namespace bdep
// When it comes to external programs (such as curl, git, etc), if stderr
// is not a terminal, the logic is actually tri-state: With --no-progress
- // we suppress any progress. With --progress (which we may add in the
- // future), we request full progress. Finally, without any --*progress
- // options we let the external program decide what to do: it may do
- // something intelligent (like curl) and produce non-terminal-friendly
- // progress (such as status lines printed periodically) or it may disable
- // progress all together (like git). Of course, it may also do no
- // detection and dump non-terminal-unfriendly progress in which case we
- // should probably do the detection ourselves and suppress it.
+ // we suppress any progress. With --progress, we request full progress.
+ // Finally, without any --*progress options we let the external program
+ // decide what to do: it may do something intelligent (like curl) and
+ // produce non-terminal-friendly progress (such as status lines printed
+ // periodically) or it may disable progress all together (like git). Of
+ // course, it may also do no detection and dump non-terminal-unfriendly
+ // progress in which case we should probably do the detection ourselves
+ // and suppress it.
//
+ bool --progress
+ {
+ "Display progress indicators for long-lasting operations, such as
+ network transfers, building, etc. If printing to a terminal the
+ progress is displayed by default for low verbosity levels. Use
+ \cb{--no-progress} to suppress."
+ }
+
bool --no-progress
{
"Suppress progress indicators for long-lasting operations, such as
diff --git a/bdep/git.txx b/bdep/git.txx
index 47705df..ef81bd8 100644
--- a/bdep/git.txx
+++ b/bdep/git.txx
@@ -190,7 +190,7 @@ namespace bdep
if (progress)
{
- if (verb == 1 && stderr_term)
+ if ((verb == 1 && stderr_term) || o.progress ())
v.push_back ("--progress");
}
else
diff --git a/bdep/http-service.cxx b/bdep/http-service.cxx
index 84be22e..c3ddc5c 100644
--- a/bdep/http-service.cxx
+++ b/bdep/http-service.cxx
@@ -55,22 +55,25 @@ namespace bdep
// Map the verbosity level.
//
cstrings v;
- bool progress (!o.no_progress ());
auto suppress_progress = [&v] ()
{
v.push_back ("-s");
v.push_back ("-S"); // But show errors.
};
+ bool sp (o.no_progress ());
if (verb < 1)
{
- suppress_progress ();
- progress = true; // No need to suppress (already done).
+ if (!o.progress ())
+ {
+ suppress_progress ();
+ sp = false; // No need to suppress (already done).
+ }
}
- else if (verb == 1 && fdterm (2))
+ else if (verb == 1)
{
- if (progress)
+ if (fdterm (2) && !sp)
v.push_back ("--progress-bar");
}
else if (verb > 3)
@@ -81,7 +84,7 @@ namespace bdep
// Note: the `-v -s` options combination is valid and results in a
// verbose output without progress.
//
- if (!progress)
+ if (sp)
suppress_progress ();
// Convert the submit arguments to curl's --form* options and cache the
diff --git a/bdep/publish.cxx b/bdep/publish.cxx
index bae4316..ee3bf9d 100644
--- a/bdep/publish.cxx
+++ b/bdep/publish.cxx
@@ -773,7 +773,7 @@ namespace bdep
}
}));
- if (verb && !o.no_progress ())
+ if ((verb && !o.no_progress ()) || o.progress ())
text << "pushing branch build2-control";
git_push (o,
@@ -793,7 +793,7 @@ namespace bdep
// The path points into the temporary directory so let's omit the
// directory part.
//
- if (verb && !o.no_progress ())
+ if ((verb && !o.no_progress ()) || o.progress ())
text << "submitting " << p.archive.leaf ();
url u (o.repository ());
diff --git a/bdep/release.cxx b/bdep/release.cxx
index 0e0f0a6..29eb3ab 100644
--- a/bdep/release.cxx
+++ b/bdep/release.cxx
@@ -1286,7 +1286,7 @@ namespace bdep
if (*push)
{
- if (verb && !o.no_progress ())
+ if ((verb && !o.no_progress ()) || o.progress ())
{
diag_record dr (text);
dr << "pushing";
diff --git a/bdep/utility.txx b/bdep/utility.txx
index 86a7b60..12bc06c 100644
--- a/bdep/utility.txx
+++ b/bdep/utility.txx
@@ -91,7 +91,7 @@ namespace bdep
string vl;
{
const char* o (nullptr);
- bool progress (!co.no_progress ());
+ bool no_progress (co.no_progress ());
switch (verb)
{
@@ -111,10 +111,13 @@ namespace bdep
ops.push_back (o);
if (strcmp (o, "-q") == 0)
- progress = true; // No need to suppress (already done with -q).
+ no_progress = false; // No need to suppress (already done with -q).
}
- if (!progress)
+ if (co.progress ())
+ ops.push_back ("--progress");
+
+ if (no_progress)
ops.push_back ("--no-progress");
}
@@ -189,7 +192,7 @@ namespace bdep
string vl;
{
const char* o (nullptr);
- bool progress (!co.no_progress ());
+ bool no_progress (co.no_progress ());
switch (verb)
{
@@ -209,10 +212,13 @@ namespace bdep
ops.push_back (o);
if (strcmp (o, "-q") == 0)
- progress = true; // No need to suppress (already done with -q).
+ no_progress = false; // No need to suppress (already done with -q).
}
- if (!progress)
+ if (co.progress ())
+ ops.push_back ("--progress");
+
+ if (no_progress)
ops.push_back ("--no-progress");
}