summaryrefslogtreecommitdiff
path: root/src/del.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/del.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/del.c')
-rw-r--r--src/del.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/del.c b/src/del.c
index 8cfdfcf..fb9b1c2 100644
--- a/src/del.c
+++ b/src/del.c
@@ -20,8 +20,7 @@ struct del_ctx {
struct apk_dependency_array *world;
};
-static int del_parse(void *pctx, struct apk_db_options *db,
- 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 del_ctx *ctx = (struct del_ctx *) pctx;
@@ -30,11 +29,23 @@ static int del_parse(void *pctx, struct apk_db_options *db,
ctx->recursive_delete = 1;
break;
default:
- return -1;
+ return -ENOTSUP;
}
return 0;
}
+static const struct apk_option options_applet[] = {
+ { 'r', "rdepends", "Recursively delete all top-level reverse "
+ "dependencies too" },
+};
+
+static const struct apk_option_group optgroup_applet = {
+ .name = "Delete",
+ .options = options_applet,
+ .num_options = ARRAY_SIZE(options_applet),
+ .parse = option_parse_applet,
+};
+
struct not_deleted_ctx {
struct apk_indent indent;
struct apk_name *name;
@@ -137,20 +148,13 @@ static int del_main(void *pctx, struct apk_database *db, struct apk_string_array
return r;
}
-static struct apk_option del_options[] = {
- { 'r', "rdepends", "Recursively delete all top-level reverse "
- "dependencies too" },
-};
-
static struct apk_applet apk_del = {
.name = "del",
.help = "Remove PACKAGEs from 'world' and uninstall them",
.arguments = "PACKAGE...",
.open_flags = APK_OPENF_WRITE,
.context_size = sizeof(struct del_ctx),
- .num_options = ARRAY_SIZE(del_options),
- .options = del_options,
- .parse = del_parse,
+ .optgroups = { &optgroup_global, &optgroup_commit, &optgroup_applet },
.main = del_main,
};