X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/6079b276a959086ff18302cab752b6d7cfe5ad9f..c094c868786f70bef8a00625fd62be1fa404b220:/apt-private/private-cmndline.cc?ds=inline diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc index d80168fda..4e80314f1 100644 --- a/apt-private/private-cmndline.cc +++ b/apt-private/private-cmndline.cc @@ -362,6 +362,25 @@ std::vector getCommandArgs(APT_CMD const Program, char const /*}}}*/ #undef CmdMatches #undef addArg +static bool ShowCommonHelp(APT_CMD const Binary, CommandLine &CmdL, aptDispatchWithHelp const * Cmds)/*{{{*/ +{ + std::cout << PACKAGE << " " << PACKAGE_VERSION << " (" << COMMON_ARCH << ")" << std::endl; + if (_config->FindB("version") == true && Binary != APT_CMD::APT_GET) + return true; + return ShowHelp(CmdL, Cmds); +} + /*}}}*/ +void ShowHelpListCommands(aptDispatchWithHelp const * Cmds) /*{{{*/ +{ + std::cout << _("Commands:") << std::endl; + for (; Cmds->Handler != nullptr; ++Cmds) + { + if (Cmds->Help == nullptr) + continue; + std::cout << " " << Cmds->Match << " - " << Cmds->Help << std::endl; + } +} + /*}}}*/ static void BinarySpecificConfiguration(char const * const Binary) /*{{{*/ { std::string const binary = flNotDir(Binary); @@ -372,6 +391,8 @@ static void BinarySpecificConfiguration(char const * const Binary) /*{{{*/ _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); @@ -397,6 +418,11 @@ std::vector ParseCommandLine(CommandLine &CmdL, APT_CMD c std::vector const CmdsWithHelp = GetCommands(); std::vector 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}); @@ -414,7 +440,7 @@ std::vector ParseCommandLine(CommandLine &CmdL, APT_CMD c (Sys != NULL && pkgInitSystem(*_config, *Sys) == false)) { if (_config->FindB("version") == true) - ShowHelp(CmdL, CmdsWithHelp.data()); + ShowCommonHelp(Binary, CmdL, CmdsWithHelp.data()); _error->DumpErrors(); exit(100); @@ -424,12 +450,12 @@ std::vector ParseCommandLine(CommandLine &CmdL, APT_CMD c if (_config->FindB("help") == true || _config->FindB("version") == true || (CmdL.FileSize() > 0 && strcmp(CmdL.FileList[0], "help") == 0)) { - ShowHelp(CmdL, CmdsWithHelp.data()); + ShowCommonHelp(Binary, CmdL, CmdsWithHelp.data()); exit(0); } if (Cmds.empty() == false && CmdL.FileSize() == 0) { - ShowHelp(CmdL, CmdsWithHelp.data()); + ShowCommonHelp(Binary, CmdL, CmdsWithHelp.data()); exit(1); } return Cmds;