#include <apt-pkg/cmndline.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/fileutl.h>
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/init.h>
#include <apt-pkg/error.h>
{
addArg('i', "important", "APT::Cache::Important", 0);
}
- else if (CmdMatches("gencaches", "showsrc", "showpkg", "stats", "dump",
+ else if (CmdMatches("showsrc"))
+ {
+ addArg(0,"only-source","APT::Cache::Only-Source",0);
+ }
+ else if (CmdMatches("gencaches", "showpkg", "stats", "dump",
"dumpavail", "showauto", "policy", "madison"))
;
else
static bool addArgumentsAPTMark(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
{
if (CmdMatches("auto", "manual", "hold", "unhold", "showauto",
- "showmanual", "showhold", "showholds", "install",
+ "showmanual", "showhold", "showholds",
"markauto", "unmarkauto"))
+ {
+ addArg('f',"file","Dir::State::extended_states",CommandLine::HasArg);
+ }
+ else if (CmdMatches("install", "remove", "deinstall", "purge",
+ "showinstall", "showinstalls", "showremove", "showremoves",
+ "showdeinstall", "showdeinstalls", "showpurge", "showpurges"))
;
else
return false;
- addArg('v',"verbose","APT::MarkAuto::Verbose",0);
- addArg('s',"simulate","APT::Mark::Simulate",0);
- addArg('s',"just-print","APT::Mark::Simulate",0);
- addArg('s',"recon","APT::Mark::Simulate",0);
- addArg('s',"dry-run","APT::Mark::Simulate",0);
- addArg('s',"no-act","APT::Mark::Simulate",0);
- addArg('f',"file","Dir::State::extended_states",CommandLine::HasArg);
+ if (CmdMatches("markauto", "unmarkauto"))
+ {
+ addArg('v',"verbose","APT::MarkAuto::Verbose",0);
+ }
+
+ if (strncmp(Cmd, "show", strlen("show")) != 0)
+ {
+ addArg('s',"simulate","APT::Mark::Simulate",0);
+ addArg('s',"just-print","APT::Mark::Simulate",0);
+ addArg('s',"recon","APT::Mark::Simulate",0);
+ addArg('s',"dry-run","APT::Mark::Simulate",0);
+ addArg('s',"no-act","APT::Mark::Simulate",0);
+ }
return true;
}
{
if (CmdMatches("list"))
{
- addArg(0,"installed","APT::Cmd::Installed",0);
+ addArg('i',"installed","APT::Cmd::Installed",0);
addArg(0,"upgradeable","APT::Cmd::Upgradable",0);
- addArg(0,"upgradable","APT::Cmd::Upgradable",0);
+ addArg('u',"upgradable","APT::Cmd::Upgradable",0);
addArg(0,"manual-installed","APT::Cmd::Manual-Installed",0);
addArg('v', "verbose", "APT::Cmd::List-Include-Summary", 0);
addArg('a', "all-versions", "APT::Cmd::All-Versions", 0);
/*}}}*/
#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::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::Get::Upgrade-Allow-New", true);
+ _config->CndSet("Binary::apt::APT::Cmd::Show-Update-Stats", true);
+ _config->CndSet("Binary::apt::DPkg::Progress-Fancy", 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))
{
CmdL = CommandLine(Args,_config);
- if ((Cnf != NULL && pkgInitConfig(**Cnf) == false) ||
- CmdL.Parse(argc,argv) == false ||
+ if (Cnf != NULL && pkgInitConfig(**Cnf) == false)
+ {
+ _error->DumpErrors();
+ exit(100);
+ }
+
+ if (likely(argc != 0 && argv[0] != NULL))
+ BinarySpecificConfiguration(argv[0]);
+
+ if (CmdL.Parse(argc,argv) == false ||
(Sys != NULL && pkgInitSystem(*_config, *Sys) == false))
{
if (_config->FindB("version") == true)