improve --help output
apk --help will list the generic options only and give a list of commands To get the details for a spefic command, 'apk command --help' should be used.cute-signatures
parent
20a1217e86
commit
61213c4018
|
@ -182,7 +182,7 @@ static struct option add_options[] = {
|
|||
|
||||
static struct apk_applet apk_add = {
|
||||
.name = "add",
|
||||
.usage = "[--initdb] [--upgrade|-u] [--virtual metaname] apkname...",
|
||||
.usage = "[--initdb] [-u|--upgrade] [-t|--virtual NAME] PACKAGE...",
|
||||
.context_size = sizeof(struct add_ctx),
|
||||
.num_options = ARRAY_SIZE(add_options),
|
||||
.options = add_options,
|
||||
|
|
42
src/apk.c
42
src/apk.c
|
@ -43,20 +43,29 @@ int version(void)
|
|||
printf("apk-tools " APK_VERSION "\n");
|
||||
return 0;
|
||||
}
|
||||
int usage(void)
|
||||
{
|
||||
struct apk_applet **a, *applet;
|
||||
|
||||
version();
|
||||
printf("\nUsage:\n");
|
||||
int generic_usage(void)
|
||||
{
|
||||
struct apk_applet **a;
|
||||
printf("usage: apk COMMAND [-h|--help] [-p|--root DIR] [-X|--repository REPO]\n"
|
||||
"\t\t [-q|--quiet] [-v|--verbose] [-V|--version] [-f|--force]\n"
|
||||
"\t\t [--progress] [--clean-protected] [--simulate] [ARGS]...\n\n"
|
||||
"commands: ");
|
||||
|
||||
for (a = &__start_apkapplets; a < &__stop_apkapplets; a++) {
|
||||
applet = *a;
|
||||
printf(" apk %s %s\n",
|
||||
applet->name, applet->usage);
|
||||
printf("%s ",
|
||||
(*a)->name);
|
||||
}
|
||||
printf("\nThis apk has coffee making abilities.\n\n");
|
||||
printf("\n\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int usage(struct apk_applet *applet)
|
||||
{
|
||||
version();
|
||||
if (applet == NULL)
|
||||
return generic_usage();
|
||||
printf("usage: apk %s %s\n\n", applet->name, applet->usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -110,8 +119,9 @@ static struct apk_repository_url *apk_repository_new(const char *url)
|
|||
return r;
|
||||
}
|
||||
|
||||
#define NUM_GENERIC_OPTS 9
|
||||
#define NUM_GENERIC_OPTS 10
|
||||
static struct option generic_options[32] = {
|
||||
{ "help", no_argument, NULL, 'h'},
|
||||
{ "root", required_argument, NULL, 'p' },
|
||||
{ "repository", required_argument, NULL, 'X' },
|
||||
{ "quiet", no_argument, NULL, 'q' },
|
||||
|
@ -165,6 +175,9 @@ int main(int argc, char **argv)
|
|||
switch (r) {
|
||||
case 0:
|
||||
break;
|
||||
case 'h':
|
||||
return usage(applet);
|
||||
break;
|
||||
case 'p':
|
||||
apk_root = optarg;
|
||||
break;
|
||||
|
@ -194,17 +207,16 @@ int main(int argc, char **argv)
|
|||
apk_flags |= APK_SIMULATE;
|
||||
break;
|
||||
default:
|
||||
if (applet == NULL || applet->parse == NULL)
|
||||
return usage();
|
||||
if (applet->parse(ctx, r, optindex - NUM_GENERIC_OPTS,
|
||||
if (applet == NULL || applet->parse == NULL ||
|
||||
applet->parse(ctx, r, optindex - NUM_GENERIC_OPTS,
|
||||
optarg) != 0)
|
||||
return usage();
|
||||
return usage(applet);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (applet == NULL)
|
||||
return usage();
|
||||
return usage(NULL);
|
||||
|
||||
if (apk_root == NULL)
|
||||
apk_root = "/";
|
||||
|
|
|
@ -60,7 +60,7 @@ out:
|
|||
|
||||
static struct apk_applet apk_del = {
|
||||
.name = "del",
|
||||
.usage = "apkname...",
|
||||
.usage = "PACKAGE...",
|
||||
.main = del_main,
|
||||
};
|
||||
|
||||
|
|
|
@ -193,7 +193,8 @@ static struct option fetch_options[] = {
|
|||
|
||||
static struct apk_applet apk_fetch = {
|
||||
.name = "fetch",
|
||||
.usage = "[-R|--recursive|--stdout] [--link|-L] [-o dir] apkname...",
|
||||
.usage = "[-R|--recursive|--stdout] [-L|--link] [-o|--output DIR]\n"
|
||||
"\t\t PACKAGE...",
|
||||
.context_size = sizeof(struct fetch_ctx),
|
||||
.num_options = ARRAY_SIZE(fetch_options),
|
||||
.options = fetch_options,
|
||||
|
|
|
@ -119,7 +119,7 @@ static struct option index_options[] = {
|
|||
|
||||
static struct apk_applet apk_index = {
|
||||
.name = "index",
|
||||
.usage = "[-d indexfile] apkname...",
|
||||
.usage = "[-d|--delete INDEXFILE] FILE...",
|
||||
.context_size = sizeof(struct index_ctx),
|
||||
.num_options = ARRAY_SIZE(index_options),
|
||||
.options = index_options,
|
||||
|
|
|
@ -266,7 +266,8 @@ static struct option info_options[] = {
|
|||
|
||||
static struct apk_applet apk_info = {
|
||||
.name = "info",
|
||||
.usage = "",
|
||||
.usage = "[-L|--contents] [-e|--installed] [-W|--who-owns] [-R|--depends]\n"
|
||||
"\t\t[-r|--rdepends] PACKAGE...",
|
||||
.context_size = sizeof(struct info_ctx),
|
||||
.num_options = ARRAY_SIZE(info_options),
|
||||
.options = info_options,
|
||||
|
|
|
@ -28,7 +28,6 @@ struct search_query_ctx {
|
|||
|
||||
static int search_list_print(apk_hash_item item, void *ctx)
|
||||
{
|
||||
//struct apk_database *db = (struct apk_database *) ctx;
|
||||
struct apk_package *pkg = (struct apk_package *) item;
|
||||
|
||||
printf("%s", pkg->name->name);
|
||||
|
@ -137,7 +136,7 @@ static struct option search_options[] = {
|
|||
|
||||
static struct apk_applet apk_search = {
|
||||
.name = "search",
|
||||
.usage = "[--description|-d] [search_pattern]",
|
||||
.usage = "[--description|-d] PATTERN",
|
||||
.context_size = sizeof(struct search_ctx),
|
||||
.num_options = ARRAY_SIZE(search_options),
|
||||
.options = search_options,
|
||||
|
|
|
@ -114,7 +114,7 @@ static struct option ver_options[] = {
|
|||
|
||||
static struct apk_applet apk_ver = {
|
||||
.name = "version",
|
||||
.usage = "[-t version1 version2]",
|
||||
.usage = "[-t|--test version1 version2] [-c|--check]",
|
||||
.context_size = sizeof(struct ver_ctx),
|
||||
.num_options = ARRAY_SIZE(ver_options),
|
||||
.options = ver_options,
|
||||
|
|
Loading…
Reference in New Issue