From 501cd23e1e85e59d18e883496a0d7f7576778054 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 16 Oct 2015 21:34:51 +0200 Subject: centralize 'show' implementation of apt and apt-cache The show commands have different styles in both binaries as the audience is potentially very different, but that doesn't mean we need to separate the implementation especially as they are slightly similar. This also allows us to switch between the different show versions at runtime via an option. Git-Dch: Ignore --- apt-private/private-cmndline.cc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'apt-private/private-cmndline.cc') diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc index 81352d757..1299b85f0 100644 --- a/apt-private/private-cmndline.cc +++ b/apt-private/private-cmndline.cc @@ -319,6 +319,21 @@ std::vector getCommandArgs(char const * const Program, char c /*}}}*/ #undef CmdMatches #undef addArg +static void BinarySpecificConfiguration(char const * const Binary) /*{{{*/ +{ + std::string const binary = flNotDir(Binary); + if (binary == "apt" || binary == "apt-config") + { + _config->CndSet("Binary::apt::APT::Cache::Show::Version", 2); + _config->CndSet("Binary::apt::APT::Cache::AllVersions", false); + _config->CndSet("Binary::apt::APT::Cache::ShowVirtuals", true); + } + + _config->Set("Binary", binary); + std::string const conf = "Binary::" + binary; + _config->MoveSubTree(conf.c_str(), NULL); +} + /*}}}*/ void ParseCommandLine(CommandLine &CmdL, CommandLine::Dispatch * const Cmds, CommandLine::Args * const Args,/*{{{*/ Configuration * const * const Cnf, pkgSystem ** const Sys, int const argc, const char *argv[], bool(*ShowHelp)(CommandLine &CmdL)) { @@ -330,12 +345,7 @@ void ParseCommandLine(CommandLine &CmdL, CommandLine::Dispatch * const Cmds, Com } if (likely(argc != 0 && argv[0] != NULL)) - { - std::string const binary = flNotDir(argv[0]); - _config->Set("Binary", binary); - std::string const conf = "Binary::" + binary; - _config->MoveSubTree(conf.c_str(), NULL); - } + BinarySpecificConfiguration(argv[0]); if (CmdL.Parse(argc,argv) == false || (Sys != NULL && pkgInitSystem(*_config, *Sys) == false)) -- cgit v1.2.3