From 2b0660b537581e9e65180e4cf1a94d763fd66847 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 25 Oct 2015 12:35:00 +0100 Subject: new quiet level -qq for apt to hide progress output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -q is for logging and -qqq (old -qq) basically kills every output expect errors, so there should be a way of declaring a middleground in which the output of e.g. 'update' isn't as verbose, but still shows some things. The test framework was actually making use of by accident as it ignored the quiet level in output setup for apt before. Eventually we should figure out some better quiet levels for all tools… --- cmdline/apt-get.cc | 13 +++---------- cmdline/apt-helper.cc | 4 +--- cmdline/apt.cc | 18 ++++++++++++------ 3 files changed, 16 insertions(+), 19 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 1379c607e..2a19360c8 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -595,14 +595,12 @@ static bool DoDownload(CommandLine &CmdL) if (verset.empty() == true) return false; - AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0)); - pkgAcquire Fetcher(&Stat); - pkgRecords Recs(Cache); pkgSourceList *SrcList = Cache.GetSourceList(); // reuse the usual acquire methods for deb files, but don't drop them into // the usual directories - keep everything in the current directory + aptAcquireWithTextStatus Fetcher; std::vector storefile(verset.size()); std::string const cwd = SafeGetCWD(); _config->Set("Dir::Cache::Archives", cwd); @@ -693,10 +691,6 @@ static bool DoSource(CommandLine &CmdL) if (_error->PendingError() == true) return false; - // Create the download object - AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0)); - pkgAcquire Fetcher(&Stat); - std::unique_ptr Dsc(new DscFile[CmdL.FileSize()]); // insert all downloaded uris into this set to avoid downloading them @@ -711,6 +705,7 @@ static bool DoSource(CommandLine &CmdL) bool const dscOnly = _config->FindB("APT::Get::Dsc-Only", false); // Load the requestd sources into the fetcher + aptAcquireWithTextStatus Fetcher; unsigned J = 0; std::vector UntrustedList; for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++) @@ -1368,13 +1363,11 @@ static bool DoChangelog(CommandLine &CmdL) CmdL.FileList + 1, APT::CacheSetHelper::CANDIDATE, helper); if (verset.empty() == true) return false; - pkgAcquire Fetcher; - AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0)); - Fetcher.SetLog(&Stat); bool const downOnly = _config->FindB("APT::Get::Download-Only", false); bool const printOnly = _config->FindB("APT::Get::Print-URIs", false); + aptAcquireWithTextStatus Fetcher; for (APT::VersionList::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver) diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc index ff9061dc7..186fded17 100644 --- a/cmdline/apt-helper.cc +++ b/cmdline/apt-helper.cc @@ -50,9 +50,7 @@ static bool DoDownloadFile(CommandLine &CmdL) if (CmdL.FileSize() <= 2) return _error->Error(_("Must specify at least one pair url/filename")); - AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0)); - pkgAcquire Fetcher(&Stat); - + aptAcquireWithTextStatus Fetcher; size_t fileind = 0; std::vector targetfiles; while (fileind + 2 <= CmdL.FileSize()) diff --git a/cmdline/apt.cc b/cmdline/apt.cc index 98e715625..eb16b561c 100644 --- a/cmdline/apt.cc +++ b/cmdline/apt.cc @@ -39,10 +39,10 @@ static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds) { - ioprintf(c1out, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); + ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); // FIXME: generate from CommandLine - c1out << + std::cout << _("Usage: apt [options] command\n" "\n" "CLI for apt.\n") @@ -87,13 +87,19 @@ int main(int argc, const char *argv[]) /*{{{*/ {nullptr, nullptr, nullptr} }; - // FIXME: Those ignore commandline configuration like -q - InitSignals(); - InitOutput(); - CommandLine CmdL; ParseCommandLine(CmdL, Cmds, "apt", &_config, &_system, argc, argv, ShowHelp); + int const quiet = _config->FindI("quiet", 0); + if (quiet == 2) + { + _config->CndSet("quiet::NoProgress", true); + _config->Set("quiet", 1); + } + + InitSignals(); + InitOutput(); + CheckIfCalledByScript(argc, argv); CheckIfSimulateMode(CmdL); -- cgit v1.2.3