+ std::string const binary = flNotDir(Binary);
+ if (binary == "apt" || binary == "apt-config")
+ {
+ _config->CndSet("Binary::apt::APT::Color", true);
+ _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->CndSet("Binary::apt::APT::Cache::Search::Version", 2);
+ _config->CndSet("Binary::apt::APT::Cache::ShowDependencyType", true);
+ _config->CndSet("Binary::apt::APT::Cache::ShowVersion", true);
+ _config->CndSet("Binary::apt::APT::Get::Upgrade-Allow-New", true);
+ _config->CndSet("Binary::apt::APT::Cmd::Show-Update-Stats", true);
+ _config->CndSet("Binary::apt::DPkg::Progress-Fancy", true);
+ _config->CndSet("Binary::apt::APT::Keep-Downloaded-Packages", false);
+ }
+ if (binary == "apt-config")
+ _config->CndSet("Binary::apt-get::Acquire::AllowInsecureRepositories", true);
+
+ _config->Set("Binary", binary);
+}
+ /*}}}*/
+static void BinaryCommandSpecificConfiguration(char const * const Binary, char const * const Cmd)/*{{{*/
+{
+ std::string const binary = flNotDir(Binary);
+ if (binary == "apt-get" && CmdMatches("update"))
+ _config->CndSet("Binary::apt-get::Acquire::AllowInsecureRepositories", true);
+}
+#undef CmdMatches
+ /*}}}*/
+std::vector<CommandLine::Dispatch> ParseCommandLine(CommandLine &CmdL, APT_CMD const Binary,/*{{{*/
+ Configuration * const * const Cnf, pkgSystem ** const Sys, int const argc, const char *argv[],
+ bool (*ShowHelp)(CommandLine &), std::vector<aptDispatchWithHelp> (*GetCommands)(void))
+{
+ InitLocale(Binary);
+ if (Cnf != NULL && pkgInitConfig(**Cnf) == false)
+ {
+ _error->DumpErrors();
+ exit(100);
+ }
+
+ if (likely(argc != 0 && argv[0] != NULL))
+ BinarySpecificConfiguration(argv[0]);
+
+ std::vector<aptDispatchWithHelp> const CmdsWithHelp = GetCommands();
+ std::vector<CommandLine::Dispatch> Cmds;
+ if (CmdsWithHelp.empty() == false)
+ {
+ CommandLine::Dispatch const help = { "help", [](CommandLine &){return false;} };
+ Cmds.push_back(std::move(help));
+ }
+ for (auto const& cmd : CmdsWithHelp)
+ Cmds.push_back({cmd.Match, cmd.Handler});
+
+ // Args running out of scope invalidates the pointer stored in CmdL,
+ // but we don't use the pointer after this function, so we ignore
+ // this problem for now and figure something out if we have to.
+ char const * CmdCalled = nullptr;
+ if (Cmds.empty() == false && Cmds[0].Handler != nullptr)
+ CmdCalled = CommandLine::GetCommand(Cmds.data(), argc, argv);
+ if (CmdCalled != nullptr)
+ BinaryCommandSpecificConfiguration(argv[0], CmdCalled);
+ std::string const conf = "Binary::" + _config->Find("Binary");
+ _config->MoveSubTree(conf.c_str(), nullptr);
+ auto Args = getCommandArgs(Binary, CmdCalled);
+ CmdL = CommandLine(Args.data(), _config);
+
+ if (CmdL.Parse(argc,argv) == false ||