summaryrefslogtreecommitdiff
path: root/src/app_list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/app_list.c')
-rw-r--r--src/app_list.c71
1 files changed, 39 insertions, 32 deletions
diff --git a/src/app_list.c b/src/app_list.c
index f46d30f..7f141f5 100644
--- a/src/app_list.c
+++ b/src/app_list.c
@@ -187,38 +187,57 @@ static void print_result(struct apk_database *db, const char *match, struct apk_
iterate_providers(name, ctx);
}
-static int option_parse_applet(void *pctx, struct apk_db_options *dbopts, int optch, const char *optarg)
+enum {
+ OPT_LIST_available,
+ OPT_LIST_installed,
+ OPT_LIST_depends,
+ OPT_LIST_origin,
+ OPT_LIST_orphaned,
+ OPT_LIST_providers,
+ OPT_LIST_upgradeable,
+};
+
+static const char option_desc[] =
+ APK_OPTAPPLET
+ APK_OPT2n("available", "a")
+ APK_OPT2n("installed", "I")
+ APK_OPT2n("depends", "d")
+ APK_OPT2n("origin", "o")
+ APK_OPT2n("orphaned", "O")
+ APK_OPT2n("providers", "P")
+ APK_OPT2n("upgradeable", "u");
+
+static int option_parse_applet(void *pctx, struct apk_db_options *dbopts, int opt, const char *optarg)
{
struct list_ctx *ctx = pctx;
- switch (optch)
- {
- case 'I':
+ switch (opt) {
+ case OPT_LIST_available:
+ ctx->available = 1;
+ ctx->orphaned = 0;
+ break;
+ case OPT_LIST_installed:
ctx->installed = 1;
break;
- case 'O':
+ case OPT_LIST_depends:
+ ctx->match_depends = 1;
+ break;
+ case OPT_LIST_origin:
+ ctx->match_origin = 1;
+ break;
+ case OPT_LIST_orphaned:
ctx->installed = 1;
ctx->orphaned = 1;
break;
- case 'u':
+ case OPT_LIST_providers:
+ ctx->match_providers = 1;
+ break;
+ case OPT_LIST_upgradeable:
ctx->available = 1;
ctx->orphaned = 0;
ctx->installed = 0;
ctx->upgradable = 1;
break;
- case 'a':
- ctx->available = 1;
- ctx->orphaned = 0;
- break;
- case 'o':
- ctx->match_origin = 1;
- break;
- case 'd':
- ctx->match_depends = 1;
- break;
- case 'P':
- ctx->match_providers = 1;
- break;
default:
return -ENOTSUP;
}
@@ -226,20 +245,8 @@ static int option_parse_applet(void *pctx, struct apk_db_options *dbopts, int op
return 0;
}
-static const struct apk_option options_applet[] = {
- { 'I', "installed" },
- { 'O', "orphaned" },
- { 'a', "available" },
- { 'u', "upgradable" },
- { 'o', "origin" },
- { 'd', "depends" },
- { 'P', "providers" },
-};
-
static const struct apk_option_group optgroup_applet = {
- .name = "List",
- .options = options_applet,
- .num_options = ARRAY_SIZE(options_applet),
+ .desc = option_desc,
.parse = option_parse_applet,
};