summaryrefslogtreecommitdiff
path: root/src/apk_applet.h
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/apk_applet.h
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/apk_applet.h')
-rw-r--r--src/apk_applet.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/apk_applet.h b/src/apk_applet.h
index d11c259..e459435 100644
--- a/src/apk_applet.h
+++ b/src/apk_applet.h
@@ -12,6 +12,7 @@
#ifndef APK_APPLET_H
#define APK_APPLET_H
+#include <errno.h>
#include <getopt.h>
#include "apk_defines.h"
#include "apk_database.h"
@@ -24,23 +25,31 @@ struct apk_option {
const char *arg_name;
};
+struct apk_option_group {
+ const char *name;
+ int num_options;
+ const struct apk_option *options;
+
+ int (*parse)(void *ctx, struct apk_db_options *dbopts,
+ int optch, const char *optarg);
+};
+
struct apk_applet {
struct list_head node;
const char *name;
const char *arguments;
const char *help;
+ const struct apk_option_group *optgroups[4];
unsigned int open_flags, forced_flags;
int context_size;
- int num_options;
- struct apk_option *options;
- int (*parse)(void *ctx, struct apk_db_options *dbopts,
- int optch, int optindex, const char *optarg);
int (*main)(void *ctx, struct apk_database *db, struct apk_string_array *args);
};
+extern const struct apk_option_group optgroup_global, optgroup_commit;
+
void apk_applet_register(struct apk_applet *);
typedef void (*apk_init_func_t)(void);