#include <apt-private/private-cmndline.h>
#include <apt-private/private-show.h>
#include <apt-private/private-search.h>
+#include <apt-private/private-main.h>
#include <regex.h>
#include <stddef.h>
return CacheFile.BuildCaches(&Progress, true);
}
/*}}}*/
-// ShowHelp - Show a help screen /*{{{*/
-static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
+bool ShowHelp(CommandLine &, aptDispatchWithHelp const * Cmds) /*{{{*/
{
- ioprintf(cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
-
- if (_config->FindB("version") == true)
- return true;
-
std::cout <<
_("Usage: apt-cache [options] command\n"
" apt-cache [options] show pkg1 [pkg2 ...]\n"
"\n"
"apt-cache is a low-level tool used to query information\n"
"from APT's binary cache files\n")
- << std::endl
- << _("Commands:") << std::endl;
- for (; Cmds->Handler != nullptr; ++Cmds)
- {
- if (Cmds->Help == nullptr)
- continue;
- std::cout << " " << Cmds->Match << " - " << Cmds->Help << std::endl;
- }
-
+ << std::endl;
+ ShowHelpListCommands(Cmds);
std::cout << std::endl
<< _("Options:\n"
" -h This help text.\n"
return true;
}
/*}}}*/
-int main(int argc,const char *argv[]) /*{{{*/
+std::vector<aptDispatchWithHelp> GetCommands() /*{{{*/
{
- CommandLine::DispatchWithHelp Cmds[] = {
+ return {
{"gencaches",&GenCaches, nullptr},
{"showsrc",&ShowSrcPackage, _("Show source records")},
{"showpkg",&DumpPackage, nullptr},
{"madison",&Madison, nullptr},
{nullptr, nullptr, nullptr}
};
-
- std::vector<CommandLine::Args> Args = getCommandArgs("apt-cache", CommandLine::GetCommand(Cmds, argc, argv));
-
- // Set up gettext support
- setlocale(LC_ALL,"");
- textdomain(PACKAGE);
+}
+ /*}}}*/
+int main(int argc,const char *argv[]) /*{{{*/
+{
+ InitLocale();
// Parse the command line and initialize the package library
CommandLine CmdL;
- ParseCommandLine(CmdL, Cmds, Args.data(), &_config, &_system, argc, argv, ShowHelp);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_CACHE, &_config, &_system, argc, argv);
InitOutput();
if (_config->Exists("APT::Cache::Generate") == true)
_config->Set("pkgCacheFile::Generate", _config->FindB("APT::Cache::Generate", true));
- // Match the operation
- CmdL.DispatchArg(Cmds);
-
- // Print any errors or warnings found during parsing
- bool const Errors = _error->PendingError();
- if (_config->FindI("quiet",0) > 0)
- _error->DumpErrors();
- else
- _error->DumpErrors(GlobalError::DEBUG);
- return Errors == true ? 100 : 0;
+ return DispatchCommandLine(CmdL, Cmds);
}
/*}}}*/