summaryrefslogtreecommitdiff
path: root/src/info.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2014-10-08 15:29:27 +0300
committerTimo Teräs <timo.teras@iki.fi>2014-10-08 15:29:27 +0300
commit38e3f5463878a29e675be8430135e36b552c0ac1 (patch)
tree6487e72ccb5a65d804b3f768cd22cf353df039b8 /src/info.c
parent275dd16c42b7208723cfa84ac9c6eb0dcb8071b6 (diff)
downloadapk-tools-38e3f5463878a29e675be8430135e36b552c0ac1.tar.gz
apk-tools-38e3f5463878a29e675be8430135e36b552c0ac1.tar.bz2
apk-tools-38e3f5463878a29e675be8430135e36b552c0ac1.tar.xz
apk-tools-38e3f5463878a29e675be8430135e36b552c0ac1.zip
rework option parsing to have a group structure
Add also a new 'commit' group that is the common options for all applets that can commit package changes.
Diffstat (limited to 'src/info.c')
-rw-r--r--src/info.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/info.c b/src/info.c
index 9af28f4..4e2c430 100644
--- a/src/info.c
+++ b/src/info.c
@@ -341,8 +341,7 @@ static void print_name_info(struct apk_database *db, const char *match, struct a
info_subaction(ctx, p->pkg);
}
-static int info_parse(void *pctx, struct apk_db_options *dbopts,
- int optch, int optindex, const char *optarg)
+static int option_parse_applet(void *pctx, struct apk_db_options *dbopts, int optch, const char *optarg)
{
struct info_ctx *ctx = (struct info_ctx *) pctx;
@@ -423,7 +422,7 @@ static int info_main(void *ctx, struct apk_database *db, struct apk_string_array
return 0;
}
-static struct apk_option info_options[] = {
+static const struct apk_option options_applet[] = {
{ 'L', "contents", "List contents of the PACKAGE" },
{ 'e', "installed", "Check if PACKAGE is installed" },
{ 'W', "who-owns", "Print the package owning the specified file" },
@@ -440,15 +439,20 @@ static struct apk_option info_options[] = {
{ 'a', "all", "Print all information about PACKAGE" },
};
+static const struct apk_option_group optgroup_applet = {
+ .name = "Info",
+ .options = options_applet,
+ .num_options = ARRAY_SIZE(options_applet),
+ .parse = option_parse_applet,
+};
+
static struct apk_applet apk_info = {
.name = "info",
.help = "Give detailed information about PACKAGEs or repositores",
.arguments = "PACKAGE...",
.open_flags = APK_OPENF_READ,
.context_size = sizeof(struct info_ctx),
- .num_options = ARRAY_SIZE(info_options),
- .options = info_options,
- .parse = info_parse,
+ .optgroups = { &optgroup_global, &optgroup_applet },
.main = info_main,
};