summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2024-04-12 12:00:45 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2024-04-12 15:57:05 +0200
commit8ddfeb2fb65dd45267d8f7abfc540d2b8cb73a5c (patch)
treeb0b400bf73b79b230ee4b69ec52c7a4c5bdd2f6a
parent88b0673b0dcc4c9c917b0cb9c16cc2ca0a92a987 (diff)
OpProgress: Erase lines when done
It's interesting to the user to see the progress when it happens, but arguably once it's done it is just visual clutter, so let's not write newlines, and when we are done, instead of appending "Done", let's just empty the line. This requires some effort to keep apt-cdrom happy which just writes lines to stdout itself. Bad apt-cdrom. Maybe there is a better fix for it, but this gets us going.
-rw-r--r--apt-pkg/contrib/progress.cc11
-rw-r--r--apt-private/private-cmndline.cc4
-rw-r--r--doc/examples/configure-index1
3 files changed, 12 insertions, 4 deletions
diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc
index a2c4332ca..df068e43a 100644
--- a/apt-pkg/contrib/progress.cc
+++ b/apt-pkg/contrib/progress.cc
@@ -153,13 +153,15 @@ void OpTextProgress::Done()
{
if (NoUpdate == false && OldOp.empty() == false)
{
- char S[300];
+ char S[300] = {};
if (_error->PendingError() == true)
snprintf(S,sizeof(S),_("%c%s... Error!"),'\r',OldOp.c_str());
- else
+ else if (not _config->FindB("APT::Internal::OpProgress::EraseLines", true))
snprintf(S,sizeof(S),_("%c%s... Done"),'\r',OldOp.c_str());
Write(S);
- cout << endl;
+ // FIXME: apt-cdrom relies on this end of line being printed
+ if (_error->PendingError() || not _config->FindB("APT::Internal::OpProgress::EraseLines", true))
+ cout << endl;
OldOp = string();
}
@@ -200,7 +202,8 @@ void OpTextProgress::Update()
{
snprintf(S,sizeof(S),"\r%s",OldOp.c_str());
Write(S);
- cout << endl;
+ if (_config->FindB("APT::Internal::OpProgress::EraseLines", true))
+ cout << endl;
}
// Print the spinner. Absolute progress shows us a time progress.
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
index cbab22031..505f1f2b8 100644
--- a/apt-private/private-cmndline.cc
+++ b/apt-private/private-cmndline.cc
@@ -481,6 +481,10 @@ static bool ShowCommonHelp(APT_CMD const Binary, CommandLine &CmdL, std::vector<
static void BinarySpecificConfiguration(char const * const Binary) /*{{{*/
{
std::string const binary = flNotDir(Binary);
+ if (binary == "apt-cdrom" || binary == "apt-config")
+ {
+ _config->CndSet("Binary::apt-cdrom::APT::Internal::OpProgress::EraseLines", false);
+ }
if (binary == "apt" || binary == "apt-config")
{
if (getenv("NO_COLOR") == nullptr)
diff --git a/doc/examples/configure-index b/doc/examples/configure-index
index 9a2bcbf1c..a8fc98daa 100644
--- a/doc/examples/configure-index
+++ b/doc/examples/configure-index
@@ -881,6 +881,7 @@ Rred::f "<BOOL>";
Rred::Compress "<STRING>";
APT::Internal::OpProgress::Absolute "<BOOL>";
+APT::Internal::OpProgress::EraseLines "<BOOL>";
APT::Color "<BOOL>";
update-manager::always-include-phased-updates "<BOOL>";