summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/add.c1
-rw-r--r--src/apk.c44
-rw-r--r--src/apk_applet.h7
-rw-r--r--src/cache.c1
-rw-r--r--src/del.c1
-rw-r--r--src/dot.c1
-rw-r--r--src/fetch.c1
-rw-r--r--src/fix.c1
-rw-r--r--src/index.c1
-rw-r--r--src/info.c1
-rw-r--r--src/manifest.c1
-rw-r--r--src/policy.c1
-rw-r--r--src/search.c1
-rw-r--r--src/update.c1
-rw-r--r--src/upgrade.c1
-rw-r--r--src/verify.c1
16 files changed, 52 insertions, 13 deletions
diff --git a/src/add.c b/src/add.c
index dcaa45c..0f12132 100644
--- a/src/add.c
+++ b/src/add.c
@@ -171,6 +171,7 @@ static struct apk_applet apk_add = {
"them, while ensuring that all dependencies are met",
.arguments = "PACKAGE...",
.open_flags = APK_OPENF_WRITE,
+ .command_groups = APK_COMMAND_GROUP_INSTALL,
.context_size = sizeof(struct add_ctx),
.optgroups = { &optgroup_global, &optgroup_commit, &optgroup_applet },
.main = add_main,
diff --git a/src/apk.c b/src/apk.c
index ed694d0..351de6f 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -338,6 +338,23 @@ static void print_options(int num_opts, const struct apk_option *opts)
}
}
+static void print_applets(const char *desc, unsigned int group)
+{
+ struct apk_applet *a;
+
+ printf("\n%s\n", desc);
+
+ foreach_applet(a) {
+ if (group && (a->command_groups & group) != group)
+ continue;
+
+ struct apk_indent indent = { .indent = 12 };
+ indent.x = printf(" %-*s", indent.indent - 3, a->name);
+ apk_print_indented_words(&indent, a->help);
+ printf("\n");
+ }
+}
+
static int usage(struct apk_applet *applet)
{
const struct apk_option_group **optgroups = default_optgroups;
@@ -345,16 +362,17 @@ static int usage(struct apk_applet *applet)
version();
if (applet == NULL) {
- struct apk_applet *a;
-
- print_usage("COMMAND", "[ARGS]...", default_optgroups);
+ if (apk_verbosity > 1) {
+ print_usage("COMMAND", "[ARGS]...", default_optgroups);
+ print_applets("The following commands are available:", 0);
+ } else {
+ print_applets("Installing and removing packages:", APK_COMMAND_GROUP_INSTALL);
+ print_applets("System maintenance:", APK_COMMAND_GROUP_SYSTEM);
+ print_applets("Querying information about packages:", APK_COMMAND_GROUP_QUERY);
+ print_applets("Repository maintenance:", APK_COMMAND_GROUP_REPO);
- printf("\nThe following commands are available:\n");
- foreach_applet(a) {
- struct apk_indent indent = { .indent = 12 };
- indent.x = printf(" %-*s", indent.indent - 3, a->name);
- apk_print_indented_words(&indent, a->help);
- printf("\n");
+ printf("\nUse apk <command> --help for command-specific help.\n");
+ printf("Use apk --help --verbose for a full command listing.\n");
}
} else {
struct apk_indent indent = { .indent = 2 };
@@ -366,9 +384,11 @@ static int usage(struct apk_applet *applet)
printf("\n");
}
- for (i = 0; optgroups[i]; i++) {
- printf("\n%s options:\n", optgroups[i]->name);
- print_options(optgroups[i]->num_options, optgroups[i]->options);
+ if (applet != NULL || apk_verbosity > 1) {
+ for (i = 0; optgroups[i]; i++) {
+ printf("\n%s options:\n", optgroups[i]->name);
+ print_options(optgroups[i]->num_options, optgroups[i]->options);
+ }
}
printf("\nThis apk has coffee making abilities.\n");
diff --git a/src/apk_applet.h b/src/apk_applet.h
index 0eea731..0c7687e 100644
--- a/src/apk_applet.h
+++ b/src/apk_applet.h
@@ -17,6 +17,11 @@
#include "apk_defines.h"
#include "apk_database.h"
+#define APK_COMMAND_GROUP_INSTALL 0x0001
+#define APK_COMMAND_GROUP_SYSTEM 0x0002
+#define APK_COMMAND_GROUP_QUERY 0x0004
+#define APK_COMMAND_GROUP_REPO 0x0008
+
struct apk_option {
int val;
const char *name;
@@ -42,7 +47,7 @@ struct apk_applet {
const char *help;
const struct apk_option_group *optgroups[4];
- unsigned int open_flags, forced_flags, forced_force;
+ unsigned int open_flags, forced_flags, forced_force, command_groups;
int context_size;
int (*main)(void *ctx, struct apk_database *db, struct apk_string_array *args);
diff --git a/src/cache.c b/src/cache.c
index aa43bdd..ec31bc3 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -152,6 +152,7 @@ static struct apk_applet apk_cache = {
"unneeded files from cache",
.arguments = "sync | clean | download",
.open_flags = APK_OPENF_READ|APK_OPENF_NO_SCRIPTS|APK_OPENF_CACHE_WRITE,
+ .command_groups = APK_COMMAND_GROUP_SYSTEM,
.main = cache_main,
};
diff --git a/src/del.c b/src/del.c
index 5756a3a..d1a6015 100644
--- a/src/del.c
+++ b/src/del.c
@@ -162,6 +162,7 @@ static struct apk_applet apk_del = {
.help = "Remove PACKAGEs from 'world' and uninstall them",
.arguments = "PACKAGE...",
.open_flags = APK_OPENF_WRITE,
+ .command_groups = APK_COMMAND_GROUP_INSTALL,
.context_size = sizeof(struct del_ctx),
.optgroups = { &optgroup_global, &optgroup_commit, &optgroup_applet },
.main = del_main,
diff --git a/src/dot.c b/src/dot.c
index 9c8ed4e..7dda73e 100644
--- a/src/dot.c
+++ b/src/dot.c
@@ -172,6 +172,7 @@ static struct apk_applet apk_dot = {
.help = "Generate graphviz graphs",
.arguments = "PKGMASK...",
.open_flags = APK_OPENF_READ | APK_OPENF_NO_STATE,
+ .command_groups = APK_COMMAND_GROUP_QUERY,
.context_size = sizeof(struct dot_ctx),
.optgroups = { &optgroup_global, &optgroup_applet },
.main = dot_main,
diff --git a/src/fetch.c b/src/fetch.c
index f9dc9a1..66d466e 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -349,6 +349,7 @@ static struct apk_applet apk_fetch = {
.help = "Download PACKAGEs from global repositories to a local directory",
.arguments = "PACKAGE...",
.open_flags = APK_OPENF_READ | APK_OPENF_NO_STATE,
+ .command_groups = APK_COMMAND_GROUP_REPO,
.context_size = sizeof(struct fetch_ctx),
.optgroups = { &optgroup_global, &optgroup_applet },
.main = fetch_main,
diff --git a/src/fix.c b/src/fix.c
index ae068b7..d28d913 100644
--- a/src/fix.c
+++ b/src/fix.c
@@ -119,6 +119,7 @@ static struct apk_applet apk_fix = {
"dependencies",
.arguments = "PACKAGE...",
.open_flags = APK_OPENF_WRITE,
+ .command_groups = APK_COMMAND_GROUP_SYSTEM,
.context_size = sizeof(struct fix_ctx),
.optgroups = { &optgroup_global, &optgroup_commit, &optgroup_applet },
.main = fix_main,
diff --git a/src/index.c b/src/index.c
index 35bd340..09c32ba 100644
--- a/src/index.c
+++ b/src/index.c
@@ -262,6 +262,7 @@ static struct apk_applet apk_index = {
.help = "Create repository index file from FILEs",
.arguments = "FILE...",
.open_flags = APK_OPENF_READ | APK_OPENF_NO_STATE | APK_OPENF_NO_REPOS,
+ .command_groups = APK_COMMAND_GROUP_REPO,
.context_size = sizeof(struct index_ctx),
.optgroups = { &optgroup_global, &optgroup_applet },
.main = index_main,
diff --git a/src/info.c b/src/info.c
index f3b9909..ff79eaa 100644
--- a/src/info.c
+++ b/src/info.c
@@ -475,6 +475,7 @@ static struct apk_applet apk_info = {
.help = "Give detailed information about PACKAGEs or repositories",
.arguments = "PACKAGE...",
.open_flags = APK_OPENF_READ,
+ .command_groups = APK_COMMAND_GROUP_QUERY,
.context_size = sizeof(struct info_ctx),
.optgroups = { &optgroup_global, &optgroup_applet },
.main = info_main,
diff --git a/src/manifest.c b/src/manifest.c
index 56c9d68..7d20aa2 100644
--- a/src/manifest.c
+++ b/src/manifest.c
@@ -128,6 +128,7 @@ static struct apk_applet apk_manifest = {
.help = "Show checksums of package contents",
.arguments = "PACKAGE...",
.open_flags = APK_OPENF_READ,
+ .command_groups = APK_COMMAND_GROUP_REPO,
.main = manifest_main,
};
diff --git a/src/policy.c b/src/policy.c
index 25d39b3..2fcd265 100644
--- a/src/policy.c
+++ b/src/policy.c
@@ -72,6 +72,7 @@ static struct apk_applet apk_policy = {
.name = "policy",
.help = "Show repository policy for packages",
.open_flags = APK_OPENF_READ,
+ .command_groups = APK_COMMAND_GROUP_QUERY,
.main = policy_main,
};
diff --git a/src/search.c b/src/search.c
index 62ca816..0854866 100644
--- a/src/search.c
+++ b/src/search.c
@@ -209,6 +209,7 @@ static struct apk_applet apk_search = {
.help = "Search package by PATTERNs or by indexed dependencies",
.arguments = "PATTERN",
.open_flags = APK_OPENF_READ | APK_OPENF_NO_STATE,
+ .command_groups = APK_COMMAND_GROUP_QUERY,
.context_size = sizeof(struct search_ctx),
.optgroups = { &optgroup_global, &optgroup_applet },
.main = search_main,
diff --git a/src/update.c b/src/update.c
index 02dcb5c..c7b0926 100644
--- a/src/update.c
+++ b/src/update.c
@@ -50,6 +50,7 @@ static struct apk_applet apk_update = {
.help = "Update repository indexes from all remote repositories",
.open_flags = APK_OPENF_WRITE,
.forced_force = APK_FORCE_REFRESH,
+ .command_groups = APK_COMMAND_GROUP_SYSTEM,
.main = update_main,
};
diff --git a/src/upgrade.c b/src/upgrade.c
index f5fcb41..14457b5 100644
--- a/src/upgrade.c
+++ b/src/upgrade.c
@@ -182,6 +182,7 @@ static struct apk_applet apk_upgrade = {
.name = "upgrade",
.help = "Upgrade currently installed packages to match repositories",
.open_flags = APK_OPENF_WRITE,
+ .command_groups = APK_COMMAND_GROUP_SYSTEM,
.context_size = sizeof(struct upgrade_ctx),
.optgroups = { &optgroup_global, &optgroup_commit, &optgroup_applet },
.main = upgrade_main,
diff --git a/src/verify.c b/src/verify.c
index 8dc2efe..f681f2f 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -59,6 +59,7 @@ static struct apk_applet apk_verify = {
.help = "Verify package integrity and signature",
.arguments = "FILE...",
.open_flags = APK_OPENF_READ | APK_OPENF_NO_STATE,
+ .command_groups = APK_COMMAND_GROUP_REPO,
.forced_flags = APK_ALLOW_UNTRUSTED,
.main = verify_main,
};