}
/*}}}*/
static bool addArgumentsAPTInternalSolver(std::vector<CommandLine::Args> &, char const * const)/*{{{*/
+{
+ return true;
+}
+ /*}}}*/
+static bool addArgumentsAPTHelper(std::vector<CommandLine::Args> &, char const * const)/*{{{*/
{
return true;
}
return true;
}
/*}}}*/
-std::vector<CommandLine::Args> getCommandArgs(char const * const Program, char const * const Cmd)/*{{{*/
+std::vector<CommandLine::Args> getCommandArgs(APT_CMD const Program, char const * const Cmd)/*{{{*/
{
std::vector<CommandLine::Args> Args;
Args.reserve(50);
- if (Program == NULL || Cmd == NULL)
- ; // FIXME: Invalid command supplied
+ if (Cmd == nullptr)
+ {
+ if (Program == APT_CMD::APT_EXTRACTTEMPLATES)
+ addArgumentsAPTExtractTemplates(Args, Cmd);
+ }
else if (strcmp(Cmd, "help") == 0)
; // no options for help so no need to implement it in each
- else if (strcmp(Program, "apt-get") == 0)
- addArgumentsAPTGet(Args, Cmd);
- else if (strcmp(Program, "apt-cache") == 0)
- addArgumentsAPTCache(Args, Cmd);
- else if (strcmp(Program, "apt-cdrom") == 0)
- addArgumentsAPTCDROM(Args, Cmd);
- else if (strcmp(Program, "apt-config") == 0)
- addArgumentsAPTConfig(Args, Cmd);
- else if (strcmp(Program, "apt-extracttemplates") == 0)
- addArgumentsAPTExtractTemplates(Args, Cmd);
- else if (strcmp(Program, "apt-ftparchive") == 0)
- addArgumentsAPTFTPArchive(Args, Cmd);
- else if (strcmp(Program, "apt-internal-solver") == 0)
- addArgumentsAPTInternalSolver(Args, Cmd);
- else if (strcmp(Program, "apt-mark") == 0)
- addArgumentsAPTMark(Args, Cmd);
- else if (strcmp(Program, "apt-sortpkg") == 0)
- addArgumentsAPTSortPkgs(Args, Cmd);
- else if (strcmp(Program, "apt") == 0)
- addArgumentsAPT(Args, Cmd);
+ else
+ switch (Program)
+ {
+ case APT_CMD::APT: addArgumentsAPT(Args, Cmd); break;
+ case APT_CMD::APT_GET: addArgumentsAPTGet(Args, Cmd); break;
+ case APT_CMD::APT_CACHE: addArgumentsAPTCache(Args, Cmd); break;
+ case APT_CMD::APT_CDROM: addArgumentsAPTCDROM(Args, Cmd); break;
+ case APT_CMD::APT_CONFIG: addArgumentsAPTConfig(Args, Cmd); break;
+ case APT_CMD::APT_EXTRACTTEMPLATES: addArgumentsAPTExtractTemplates(Args, Cmd); break;
+ case APT_CMD::APT_FTPARCHIVE: addArgumentsAPTFTPArchive(Args, Cmd); break;
+ case APT_CMD::APT_HELPER: addArgumentsAPTHelper(Args, Cmd); break;
+ case APT_CMD::APT_INTERNAL_SOLVER: addArgumentsAPTInternalSolver(Args, Cmd); break;
+ case APT_CMD::APT_MARK: addArgumentsAPTMark(Args, Cmd); break;
+ case APT_CMD::APT_SORTPKG: addArgumentsAPTSortPkgs(Args, Cmd); break;
+ }
// options without a command
addArg('h', "help", "help", 0);
_config->MoveSubTree(conf.c_str(), NULL);
}
/*}}}*/
-void ParseCommandLine(CommandLine &CmdL, CommandLine::DispatchWithHelp const * Cmds, char const * const Binary,/*{{{*/
- Configuration * const * const Cnf, pkgSystem ** const Sys, int const argc, const char *argv[], bool(*ShowHelp)(CommandLine &, CommandLine::DispatchWithHelp const *))
+std::vector<CommandLine::DispatchWithHelp> ParseCommandLine(CommandLine &CmdL, APT_CMD const Binary,/*{{{*/
+ Configuration * const * const Cnf, pkgSystem ** const Sys, int const argc, const char *argv[])
{
- // 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.
- std::vector<CommandLine::Args> Args;
- if (Cmds != nullptr && Cmds[0].Handler != nullptr)
- Args = getCommandArgs(Binary, CommandLine::GetCommand(Cmds, argc, argv));
- else
- Args = getCommandArgs(Binary, Binary);
- CmdL = CommandLine(Args.data(), _config);
-
if (Cnf != NULL && pkgInitConfig(**Cnf) == false)
{
_error->DumpErrors();
if (likely(argc != 0 && argv[0] != NULL))
BinarySpecificConfiguration(argv[0]);
+ std::vector<CommandLine::DispatchWithHelp> const Cmds = GetCommands();
+ // 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.
+ std::vector<CommandLine::Args> Args;
+ if (Cmds.empty() == false && Cmds[0].Handler != nullptr)
+ Args = getCommandArgs(Binary, CommandLine::GetCommand(Cmds.data(), argc, argv));
+ else
+ Args = getCommandArgs(Binary, nullptr);
+ CmdL = CommandLine(Args.data(), _config);
+
if (CmdL.Parse(argc,argv) == false ||
(Sys != NULL && pkgInitSystem(*_config, *Sys) == false))
{
if (_config->FindB("version") == true)
- ShowHelp(CmdL, Cmds);
+ ShowHelp(CmdL, Cmds.data());
_error->DumpErrors();
exit(100);
if (_config->FindB("help") == true || _config->FindB("version") == true ||
(CmdL.FileSize() > 0 && strcmp(CmdL.FileList[0], "help") == 0))
{
- ShowHelp(CmdL, Cmds);
+ ShowHelp(CmdL, Cmds.data());
exit(0);
}
- if (Cmds != nullptr && CmdL.FileSize() == 0)
+ if (Cmds.empty() == false && CmdL.FileSize() == 0)
{
- ShowHelp(CmdL, Cmds);
+ ShowHelp(CmdL, Cmds.data());
exit(1);
}
+ return Cmds;
}
/*}}}*/
-unsigned short DispatchCommandLine(CommandLine &CmdL, CommandLine::DispatchWithHelp const * const Cmds) /*{{{*/
+unsigned short DispatchCommandLine(CommandLine &CmdL, std::vector<CommandLine::DispatchWithHelp> const &Cmds) /*{{{*/
{
// Match the operation
- bool const returned = (Cmds != nullptr) ? CmdL.DispatchArg(Cmds) : true;
+ bool const returned = Cmds.empty() ? true : CmdL.DispatchArg(Cmds.data());
// Print any errors or warnings found during parsing
bool const Errors = _error->PendingError();
class Configuration;
class pkgSystem;
-APT_PUBLIC std::vector<CommandLine::Args> getCommandArgs(char const * const Program, char const * const Cmd);
-APT_PUBLIC void ParseCommandLine(CommandLine &CmdL, CommandLine::DispatchWithHelp const * Cmds, char const * const Binary,
- Configuration * const * const Cnf, pkgSystem ** const Sys, int const argc, const char * argv[],
- bool(*ShowHelp)(CommandLine &, CommandLine::DispatchWithHelp const *));
-APT_PUBLIC unsigned short DispatchCommandLine(CommandLine &CmdL, CommandLine::DispatchWithHelp const * const Cmds);
+enum class APT_CMD {
+ APT,
+ APT_GET,
+ APT_CACHE,
+ APT_CDROM,
+ APT_CONFIG,
+ APT_EXTRACTTEMPLATES,
+ APT_FTPARCHIVE,
+ APT_HELPER,
+ APT_INTERNAL_SOLVER,
+ APT_MARK,
+ APT_SORTPKG,
+};
+
+bool ShowHelp(CommandLine &CmdL, CommandLine::DispatchWithHelp const * Cmds);
+std::vector<CommandLine::DispatchWithHelp> GetCommands();
+
+APT_PUBLIC std::vector<CommandLine::DispatchWithHelp> ParseCommandLine(CommandLine &CmdL, APT_CMD const Binary,
+ Configuration * const * const Cnf, pkgSystem ** const Sys, int const argc, const char * argv[]);
+APT_PUBLIC unsigned short DispatchCommandLine(CommandLine &CmdL, std::vector<CommandLine::DispatchWithHelp> const &Cmds);
+
+APT_PUBLIC std::vector<CommandLine::Args> getCommandArgs(APT_CMD const Program, char const * const Cmd);
#endif
}
/*}}}*/
// ShowHelp - Show a help screen /*{{{*/
-static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
+bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
{
ioprintf(cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
return true;
}
/*}}}*/
-int main(int argc,const char *argv[]) /*{{{*/
+std::vector<CommandLine::DispatchWithHelp> GetCommands() /*{{{*/
{
- InitLocale();
-
- CommandLine::DispatchWithHelp Cmds[] = {
+ return {
{"gencaches",&GenCaches, nullptr},
{"showsrc",&ShowSrcPackage, _("Show source records")},
{"showpkg",&DumpPackage, nullptr},
{"madison",&Madison, nullptr},
{nullptr, nullptr, nullptr}
};
+}
+ /*}}}*/
+int main(int argc,const char *argv[]) /*{{{*/
+{
+ InitLocale();
// Parse the command line and initialize the package library
CommandLine CmdL;
- ParseCommandLine(CmdL, Cmds, "apt-cache", &_config, &_system, argc, argv, ShowHelp);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_CACHE, &_config, &_system, argc, argv);
InitOutput();
}
/*}}}*/
// ShowHelp - Show the help screen /*{{{*/
-static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
+bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
{
ioprintf(cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
return true;
}
/*}}}*/
-int main(int argc,const char *argv[]) /*{{{*/
+std::vector<CommandLine::DispatchWithHelp> GetCommands() /*{{{*/
{
- InitLocale();
-
- CommandLine::DispatchWithHelp Cmds[] = {
+ return {
{"add", &DoAdd, "Add a CDROM"},
{"ident", &DoIdent, "Report the identity of a CDROM"},
{nullptr, nullptr, nullptr}
};
+}
+ /*}}}*/
+int main(int argc,const char *argv[]) /*{{{*/
+{
+ InitLocale();
// Parse the command line and initialize the package library
CommandLine CmdL;
- ParseCommandLine(CmdL, Cmds, "apt-cdrom", &_config, &_system, argc, argv, ShowHelp);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_CDROM, &_config, &_system, argc, argv);
InitOutput();
}
/*}}}*/
// ShowHelp - Show the help screen /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
+bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
{
ioprintf(cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
if (_config->FindB("version") == true)
return true;
}
/*}}}*/
-int main(int argc,const char *argv[]) /*{{{*/
+std::vector<CommandLine::DispatchWithHelp> GetCommands() /*{{{*/
{
- InitLocale();
-
- CommandLine::DispatchWithHelp Cmds[] = {
+ return {
{"shell", &DoShell, _("get configuration values via shell evaluation")},
{"dump", &DoDump, _("show the active configuration setting")},
{nullptr, nullptr, nullptr}
};
+}
+ /*}}}*/
+int main(int argc,const char *argv[]) /*{{{*/
+{
+ InitLocale();
// Parse the command line and initialize the package library
CommandLine CmdL;
- ParseCommandLine(CmdL, Cmds, "apt-config", &_config, &_system, argc, argv, ShowHelp);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_CONFIG, &_config, &_system, argc, argv);
std::vector<std::string> const langs = APT::Configuration::getLanguages(true);
_config->Clear("Acquire::Languages");
}
/*}}}*/
// ShowHelp - show a short help text /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const *)
+bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const *)
{
ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
return !_error->PendingError();
}
/*}}}*/
+std::vector<CommandLine::DispatchWithHelp> GetCommands() /*{{{*/
+{
+ return {
+ {nullptr, nullptr, nullptr}
+ };
+}
+ /*}}}*/
int main(int argc, const char **argv) /*{{{*/
{
InitLocale();
- // Parse the command line and initialize the package library
- CommandLine::DispatchWithHelp Cmds[] = {{nullptr, nullptr, nullptr}};
CommandLine CmdL;
- ParseCommandLine(CmdL, Cmds, "apt-extracttemplates", &_config, &_system, argc, argv, ShowHelp);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_EXTRACTTEMPLATES, &_config, &_system, argc, argv);
Go(CmdL);
- return DispatchCommandLine(CmdL, nullptr);
+ return DispatchCommandLine(CmdL, {});
}
/*}}}*/
}
/*}}}*/
// ShowHelp - Show a help screen /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
+bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
{
ioprintf(cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
return true;
}
/*}}}*/
-int main(int argc,const char *argv[]) /*{{{*/
+std::vector<CommandLine::DispatchWithHelp> GetCommands() /*{{{*/
{
- InitLocale();
-
- CommandLine::DispatchWithHelp Cmds[] = {
+ return {
{"update", &DoUpdate, _("Retrieve new lists of packages")},
{"upgrade", &DoUpgrade, _("Perform an upgrade")},
{"install", &DoInstall, _("Install new packages (pkg is libc6 not libc6.deb)")},
{"moo", &DoMoo, nullptr},
{nullptr, nullptr, nullptr}
};
+}
+ /*}}}*/
+int main(int argc,const char *argv[]) /*{{{*/
+{
+ InitLocale();
// Parse the command line and initialize the package library
CommandLine CmdL;
- ParseCommandLine(CmdL, Cmds, "apt-get", &_config, &_system, argc, argv, ShowHelp);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_GET, &_config, &_system, argc, argv);
InitSignals();
InitOutput();
#include <apti18n.h>
/*}}}*/
-static bool DoAutoDetectProxy(CommandLine &CmdL)
+static bool DoAutoDetectProxy(CommandLine &CmdL) /*{{{*/
{
if (CmdL.FileSize() != 2)
return _error->Error(_("Need one URL as argument"));
return true;
}
-
-static bool DoDownloadFile(CommandLine &CmdL)
+ /*}}}*/
+static bool DoDownloadFile(CommandLine &CmdL) /*{{{*/
{
if (CmdL.FileSize() <= 2)
return _error->Error(_("Must specify at least one pair url/filename"));
return true;
}
-
-static bool DoSrvLookup(CommandLine &CmdL)
+ /*}}}*/
+static bool DoSrvLookup(CommandLine &CmdL) /*{{{*/
{
if (CmdL.FileSize() <= 1)
return _error->Error("Must specify at least one SRV record");
}
return true;
}
-
-static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
+ /*}}}*/
+bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)/*{{{*/
{
ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
_("This APT helper has Super Meep Powers.") << std::endl;
return true;
}
-
-
-int main(int argc,const char *argv[]) /*{{{*/
+ /*}}}*/
+std::vector<CommandLine::DispatchWithHelp> GetCommands() /*{{{*/
{
- InitLocale();
-
- CommandLine::DispatchWithHelp Cmds[] = {
+ return {
{"download-file", &DoDownloadFile, _("download the given uri to the target-path")},
{"srv-lookup", &DoSrvLookup, _("lookup a SRV record (e.g. _http._tcp.ftp.debian.org)")},
{"auto-detect-proxy", &DoAutoDetectProxy, _("detect proxy using apt.conf")},
{nullptr, nullptr, nullptr}
};
+}
+ /*}}}*/
+int main(int argc,const char *argv[]) /*{{{*/
+{
+ InitLocale();
- // Parse the command line and initialize the package library
CommandLine CmdL;
- ParseCommandLine(CmdL, Cmds, "apt-helper", &_config, &_system, argc, argv, ShowHelp);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_HELPER, &_config, &_system, argc, argv);
InitOutput();
/*}}}*/
// ShowHelp - Show a help screen /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const *) {
+bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const *) {
ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
std::cout <<
exit(EXIT_FAILURE);
}
/*}}}*/
+std::vector<CommandLine::DispatchWithHelp> GetCommands() /*{{{*/
+{
+ return {};
+}
+ /*}}}*/
int main(int argc,const char *argv[]) /*{{{*/
{
InitLocale();
DropPrivileges();
CommandLine CmdL;
- ParseCommandLine(CmdL, nullptr, "apt-internal-solver", &_config, NULL, argc, argv, ShowHelp);
+ ParseCommandLine(CmdL, APT_CMD::APT_INTERNAL_SOLVER, &_config, NULL, argc, argv);
if (CmdL.FileList[0] != 0 && strcmp(CmdL.FileList[0], "scenario") == 0)
{
EDSP::WriteProgress(100, "Done", output);
- return DispatchCommandLine(CmdL, nullptr);
+ return DispatchCommandLine(CmdL, {});
}
/*}}}*/
}
/*}}}*/
// ShowHelp - Show a help screen /*{{{*/
-static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
+bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
{
ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
return true;
}
/*}}}*/
-int main(int argc,const char *argv[]) /*{{{*/
+std::vector<CommandLine::DispatchWithHelp> GetCommands() /*{{{*/
{
- InitLocale();
-
- CommandLine::DispatchWithHelp Cmds[] = {
+ return {
{"auto",&DoAuto, _("Mark the given packages as automatically installed")},
{"manual",&DoAuto, _("Mark the given packages as manually installed")},
{"hold",&DoSelection, _("Mark a package as held back")},
{"unmarkauto", &DoMarkAuto, nullptr},
{nullptr, nullptr, nullptr}
};
+}
+ /*}}}*/
+int main(int argc,const char *argv[]) /*{{{*/
+{
+ InitLocale();
CommandLine CmdL;
- ParseCommandLine(CmdL, Cmds, "apt-mark", &_config, &_system, argc, argv, ShowHelp);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_MARK, &_config, &_system, argc, argv);
InitOutput();
}
/*}}}*/
// ShowHelp - Show the help text /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const *)
+bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const *)
{
ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
if (_config->FindB("version") == true)
return true;
}
/*}}}*/
+std::vector<CommandLine::DispatchWithHelp> GetCommands() /*{{{*/
+{
+ return {
+ {nullptr, nullptr, nullptr}
+ };
+}
+ /*}}}*/
int main(int argc,const char *argv[]) /*{{{*/
{
InitLocale();
- // Parse the command line and initialize the package library
- CommandLine::DispatchWithHelp Cmds[] = {{nullptr, nullptr, nullptr}};
CommandLine CmdL;
- ParseCommandLine(CmdL, Cmds, "apt-sortpkgs", &_config, &_system, argc, argv, ShowHelp);
+ ParseCommandLine(CmdL, APT_CMD::APT_SORTPKG, &_config, &_system, argc, argv);
// Match the operation
for (unsigned int I = 0; I != CmdL.FileSize(); I++)
if (DoIt(CmdL.FileList[I]) == false)
break;
- return DispatchCommandLine(CmdL, nullptr);
+ return DispatchCommandLine(CmdL, {});
}
/*}}}*/
#include <apti18n.h>
/*}}}*/
-static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
+bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)/*{{{*/
{
ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
return true;
}
-
-int main(int argc, const char *argv[]) /*{{{*/
+ /*}}}*/
+std::vector<CommandLine::DispatchWithHelp> GetCommands() /*{{{*/
{
- InitLocale();
-
- CommandLine::DispatchWithHelp Cmds[] = {
+ return {
// query
{"list", &DoList, _("list packages based on package names")},
{"search", &DoSearch, _("search in package descriptions")},
{"moo", &DoMoo, nullptr},
{nullptr, nullptr, nullptr}
};
+}
+ /*}}}*/
+int main(int argc, const char *argv[]) /*{{{*/
+{
+ InitLocale();
CommandLine CmdL;
- ParseCommandLine(CmdL, Cmds, "apt", &_config, &_system, argc, argv, ShowHelp);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT, &_config, &_system, argc, argv);
int const quiet = _config->FindI("quiet", 0);
if (quiet == 2)
/*}}}*/
// ShowHelp - Show the help text /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const *)
+bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const *)
{
ioprintf(cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
if (_config->FindB("version") == true)
}
/*}}}*/
-int main(int argc, const char *argv[])
+std::vector<CommandLine::DispatchWithHelp> GetCommands() /*{{{*/
{
- InitLocale();
-
- CommandLine::DispatchWithHelp Cmds[] = {
+ return {
{"packages",&SimpleGenPackages, nullptr},
{"contents",&SimpleGenContents, nullptr},
{"sources",&SimpleGenSources, nullptr},
{"clean",&Clean, nullptr},
{nullptr, nullptr, nullptr}
};
+}
+ /*}}}*/
+int main(int argc, const char *argv[]) /*{{{*/
+{
+ InitLocale();
// Parse the command line and initialize the package library
CommandLine CmdL;
- ParseCommandLine(CmdL, Cmds, "apt-ftparchive", &_config, NULL, argc, argv, ShowHelp);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_FTPARCHIVE, &_config, NULL, argc, argv);
_config->CndSet("quiet",0);
Quiet = _config->FindI("quiet",0);
return DispatchCommandLine(CmdL, Cmds);
}
+ /*}}}*/
char const * argv[] = { "apt-get", "-t", "unstable", "remove", "-d", "foo" };
char const * com = CommandLine::GetCommand(Cmds, sizeof(argv)/sizeof(argv[0]), argv);
EXPECT_STREQ("remove", com);
- std::vector<CommandLine::Args> Args = getCommandArgs("apt-get", com);
+ std::vector<CommandLine::Args> Args = getCommandArgs(APT_CMD::APT_GET, com);
::Configuration c;
CommandLine CmdL(Args.data(), &c);
ASSERT_TRUE(CmdL.Parse(sizeof(argv)/sizeof(argv[0]), argv));
char const * argv[] = {"apt-get", "-t", "unstable", "remove", "--", "-d", "foo" };
char const * com = CommandLine::GetCommand(Cmds, sizeof(argv)/sizeof(argv[0]), argv);
EXPECT_STREQ("remove", com);
- std::vector<CommandLine::Args> Args = getCommandArgs("apt-get", com);
+ std::vector<CommandLine::Args> Args = getCommandArgs(APT_CMD::APT_GET, com);
::Configuration c;
CommandLine CmdL(Args.data(), &c);
ASSERT_TRUE(CmdL.Parse(sizeof(argv)/sizeof(argv[0]), argv));
char const * argv[] = {"apt-get", "-t", "unstable", "--", "remove", "-d", "foo" };
char const * com = CommandLine::GetCommand(Cmds, sizeof(argv)/sizeof(argv[0]), argv);
EXPECT_STREQ("remove", com);
- std::vector<CommandLine::Args> Args = getCommandArgs("apt-get", com);
+ std::vector<CommandLine::Args> Args = getCommandArgs(APT_CMD::APT_GET, com);
::Configuration c;
CommandLine CmdL(Args.data(), &c);
ASSERT_TRUE(CmdL.Parse(sizeof(argv)/sizeof(argv[0]), argv));
char const * argv[] = {"apt-get", "install", "-t", "unstable", "--", "remove", "-d", "foo" };
char const * com = CommandLine::GetCommand(Cmds, sizeof(argv)/sizeof(argv[0]), argv);
EXPECT_STREQ("install", com);
- std::vector<CommandLine::Args> Args = getCommandArgs("apt-get", com);
+ std::vector<CommandLine::Args> Args = getCommandArgs(APT_CMD::APT_GET, com);
::Configuration c;
CommandLine CmdL(Args.data(), &c);
ASSERT_TRUE(CmdL.Parse(sizeof(argv)/sizeof(argv[0]), argv));
#include <gtest/gtest.h>
+
#include <apt-pkg/error.h>
+#include <apt-pkg/cmndline.h>
+
+bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const *) {return false;}
+std::vector<CommandLine::DispatchWithHelp> GetCommands() {return {};}
+
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
int result = RUN_ALL_TESTS();