[haiku-commits] BRANCH HaikuPM-github.package-management [0214aef] src/bin/pkgman

  • From: HaikuPM-github.package-management <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 25 Aug 2013 17:30:33 +0200 (CEST)

added 1 changeset to branch 'refs/remotes/HaikuPM-github/package-management'
old head: 8f9efca9a673d62f43e4ae26a153337a25b22ce3
new head: 0214aefd58d6ccca6fb2a7f6c6c7b57f858f422f
overview: https://github.com/haiku/HaikuPM/compare/8f9efca...0214aef

----------------------------------------------------------------------------

0214aef: pkgman search: add -a/--all
  
  Can be specified instead of a search string. Lists all packages.

                                    [ Ingo Weinhold <ingo_weinhold@xxxxxx> ]

----------------------------------------------------------------------------

Commit:      0214aefd58d6ccca6fb2a7f6c6c7b57f858f422f
Author:      Ingo Weinhold <ingo_weinhold@xxxxxx>
Date:        Sun Aug 25 15:19:14 2013 UTC

----------------------------------------------------------------------------

1 file changed, 15 insertions(+), 6 deletions(-)
src/bin/pkgman/command_search.cpp | 21 +++++++++++++++------

----------------------------------------------------------------------------

diff --git a/src/bin/pkgman/command_search.cpp 
b/src/bin/pkgman/command_search.cpp
index 371987c..5be2a10 100644
--- a/src/bin/pkgman/command_search.cpp
+++ b/src/bin/pkgman/command_search.cpp
@@ -32,14 +32,16 @@ using namespace BPackageKit;
 
 
 static const char* const kShortUsage =
-       "  %command% <search-string>\n"
+       "  %command% ( <search-string> | --all | -a )\n"
        "    Searches for packages matching <search-string>.\n";
 
 static const char* const kLongUsage =
-       "Usage: %program% %command% <search-string>\n"
+       "Usage: %program% %command% ( <search-string> | --all | -a )\n"
        "Searches for packages matching <search-string>.\n"
        "\n"
        "Options:\n"
+       "  -a, --all\n"
+       "    List all packages. Specified instead of <search-string>.\n"
        "  -i, --installed-only\n"
        "    Only find installed packages.\n"
        "  -u, --uninstalled-only\n"
@@ -68,9 +70,11 @@ SearchCommand::Execute(int argc, const char* const* argv)
 {
        bool installedOnly = false;
        bool uninstalledOnly = false;
+       bool listAll = false;
 
        while (true) {
                static struct option sLongOptions[] = {
+                       { "all", no_argument, 0, 'a' },
                        { "help", no_argument, 0, 'h' },
                        { "installed-only", no_argument, 0, 'i' },
                        { "uninstalled-only", no_argument, 0, 'u' },
@@ -78,11 +82,15 @@ SearchCommand::Execute(int argc, const char* const* argv)
                };
 
                opterr = 0; // don't print errors
-               int c = getopt_long(argc, (char**)argv, "hiu", sLongOptions, 
NULL);
+               int c = getopt_long(argc, (char**)argv, "ahiu", sLongOptions, 
NULL);
                if (c == -1)
                        break;
 
                switch (c) {
+                       case 'a':
+                               listAll = true;
+                               break;
+
                        case 'h':
                                PrintUsageAndExit(false);
                                break;
@@ -103,11 +111,12 @@ SearchCommand::Execute(int argc, const char* const* argv)
                }
        }
 
-       // The remaining argument is the search string.
-       if (argc != optind + 1)
+       // The remaining argument is the search string. Ignored when --all has 
been
+       // specified.
+       if (!listAll && argc != optind + 1)
                PrintUsageAndExit(true);
 
-       const char* searchString = argv[optind++];
+       const char* searchString = listAll ? "" : argv[optind++];
 
        // create the solver
        PackageManager packageManager(B_PACKAGE_INSTALLATION_LOCATION_COMMON,


Other related posts:

  • » [haiku-commits] BRANCH HaikuPM-github.package-management [0214aef] src/bin/pkgman - HaikuPM-github . package-management