X-Original-To: alpine-devel@lists.alpinelinux.org Delivered-To: alpine-devel@mail.alpinelinux.org Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.alpinelinux.org (Postfix) with ESMTPS id 6FAC6DC5CB2 for ; Thu, 27 Jun 2013 19:29:10 +0000 (UTC) Received: from compute2.internal (compute2.nyi.mail.srv.osa [10.202.2.42]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 5CE8B20CB8 for ; Thu, 27 Jun 2013 15:29:04 -0400 (EDT) Received: from frontend2.nyi.mail.srv.osa ([10.202.2.161]) by compute2.internal (MEProxy); Thu, 27 Jun 2013 15:29:04 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:subject:date:message-id :in-reply-to:references; s=smtpout; bh=JxwEDlAxutsSebC0h+GGZlRay 5w=; b=OvPrgc9Z2BaFlD4V7rAbY93yDWa4KVA00QfgPoVWS4D/J5SMOB61f4436 CJm1tmuHxWYzFIxzgd2rdbQcM7MwnduW0geZ8BPrcpsNIPbKV1nFIIjR0QtcUqCl 7ZqJz1XNKckkRbU9atX/m2GYMlXpaXKeS6UYa0NQZM6Rddo2mM= X-Sasl-enc: p9TaVugng/B0+o4xYFvGHuePb+dXa59xTJyEsmQYsSyB 1372361344 Received: from localhost (unknown [69.86.161.244]) by mail.messagingengine.com (Postfix) with ESMTPA id 1532C68027F for ; Thu, 27 Jun 2013 15:29:04 -0400 (EDT) From: Dubiousjim To: alpine-devel@lists.alpinelinux.org Subject: [alpine-devel] [PATCH 07/15] add -R and -D options Date: Thu, 27 Jun 2013 15:28:52 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: X-Mailinglist: alpine-devel Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: Also add infrastructure for short-option-only synonyms --- src/apk.c | 17 +++++++++-------- src/audit.c | 4 +++- src/del.c | 4 +++- src/fetch.c | 4 +++- src/fix.c | 4 +++- src/info.c | 8 +++++--- src/search.c | 4 +++- 7 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/apk.c b/src/apk.c index a1b26fb..3e3461c 100644 --- a/src/apk.c +++ b/src/apk.c @@ -110,13 +110,14 @@ static void print_usage(const char *cmd, const char *args, int num_opts, int i, j; indent.x = printf("\nusage: apk %s", cmd) - 1; - for (i = 0; i < num_opts; i++) { - j = 0; - word[j++] = '['; - j += format_option(&word[j], sizeof(word) - j, &opts[i], "|"); - word[j++] = ']'; - apk_print_indented(&indent, APK_BLOB_PTR_LEN(word, j)); - } + for (i = 0; i < num_opts; i++) + if (opts[i].name != NULL) { + j = 0; + word[j++] = '['; + j += format_option(&word[j], sizeof(word) - j, &opts[i], "|"); + word[j++] = ']'; + apk_print_indented(&indent, APK_BLOB_PTR_LEN(word, j)); + } if (args != NULL) apk_print_indented(&indent, APK_BLOB_STR(args)); printf("\n"); @@ -229,7 +230,7 @@ static void merge_options(struct option *opts, struct apk_option *ao, int num) int i; for (i = 0; i < num; i++, opts++, ao++) { - opts->name = ao->name; + opts->name = ao->name ?: ""; opts->has_arg = ao->has_arg; opts->flag = NULL; opts->val = ao->val; diff --git a/src/audit.c b/src/audit.c index 1b82c28..fb92aff 100644 --- a/src/audit.c +++ b/src/audit.c @@ -52,6 +52,7 @@ static int audit_parse(void *ctx, struct apk_db_options *dbopts, actx->packages_only = 1; break; case 'r': + case 'R': actx->recursive = 1; break; default: @@ -279,7 +280,8 @@ static struct apk_option audit_options[] = { "protected_paths.d) that need to be backed up" }, { 0x10001, "system", "Verify checksums of all installed non-configuration files " }, { 0x10002, "check-permissions", "Check file and directory uid/gid/mode too" }, - { 'r', "recursive", "List individually all entries in new directories" }, + { 'R', "recursive", "List individually all entries in new directories" }, + { 'r', NULL, "Synonym for -R (deprecated)" }, { 0x10003, "packages", "List only the changed packages (or names only with -q)" }, }; diff --git a/src/del.c b/src/del.c index 7b5fd6c..f268b33 100644 --- a/src/del.c +++ b/src/del.c @@ -27,6 +27,7 @@ static int del_parse(void *pctx, struct apk_db_options *db, switch (optch) { case 'r': + case 'R': ctx->recursive_delete = 1; break; default: @@ -129,8 +130,9 @@ static int del_main(void *pctx, struct apk_database *db, struct apk_string_array } static struct apk_option del_options[] = { - { 'r', "rdepends", "Recursively delete all top-level reverse " + { 'R', "rdepends", "Recursively delete all top-level reverse " "dependencies too" }, + { 'r', NULL, "Synonym for -R (deprecated)" }, }; static struct apk_applet apk_del = { diff --git a/src/fetch.c b/src/fetch.c index 60c31f4..059f1c8 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -77,6 +77,7 @@ static int fetch_parse(void *ctx, struct apk_db_options *dbopts, apk_flags |= APK_UPDATE_CACHE; break; case 'R': + case 'D': fctx->flags |= FETCH_RECURSIVE; break; case 's': @@ -264,7 +265,8 @@ static int fetch_main(void *pctx, struct apk_database *db, struct apk_string_arr static struct apk_option fetch_options[] = { { 'U', "update-cache", "Update the repository cache first" }, { 'L', "link", "Create hard links if possible" }, - { 'R', "recursive", "Fetch the PACKAGE and all its dependencies" }, + { 'D', "depends", "Fetch the PACKAGE and all its dependencies" }, + { 'R', "recursive", "Synonyms for -D (deprecated)" }, { 's', "stdout", "Dump the .apk to stdout (incompatible with -o and -R)" }, { 'o', "output", "Directory to place the PACKAGEs to", diff --git a/src/fix.c b/src/fix.c index e772bd9..b59af0b 100644 --- a/src/fix.c +++ b/src/fix.c @@ -28,6 +28,7 @@ static int fix_parse(void *pctx, struct apk_db_options *dbopts, struct fix_ctx *ctx = (struct fix_ctx *) pctx; switch (optch) { case 'd': + case 'D': ctx->fix_depends = 1; break; case 'U': @@ -89,7 +90,8 @@ static int fix_main(void *pctx, struct apk_database *db, struct apk_string_array static struct apk_option fix_options[] = { { 'U', "update-cache", "Update the repository cache first" }, - { 'd', "depends", "Fix all dependencies too" }, + { 'D', "depends", "Fix all dependencies too" }, + { 'd', NULL, "Synonym for -D (deprecated)" }, { 'r', "reinstall", "Reinstall the package (default)" }, { 'u', "upgrade", "Prefer to upgrade package" }, { 0x10000, "directory-permissions", "Reset all directory permissions" }, diff --git a/src/info.c b/src/info.c index f4d5b92..6859268 100644 --- a/src/info.c +++ b/src/info.c @@ -350,13 +350,14 @@ static int info_parse(void *pctx, struct apk_db_options *dbopts, case 'w': ctx->subaction_mask |= APK_INFO_URL; break; - case 'R': + case 'D': ctx->subaction_mask |= APK_INFO_DEPENDS; break; case 'P': ctx->subaction_mask |= APK_INFO_PROVIDES; break; case 'r': + case 'R': ctx->subaction_mask |= APK_INFO_RDEPENDS; break; case 'I': @@ -419,9 +420,10 @@ static struct apk_option info_options[] = { { 'L', "contents", "List contents of the PACKAGE" }, { 'e', "installed", "Check if PACKAGE is installed" }, { 'W', "who-owns", "Print the package owning the specified file" }, - { 'R', "depends", "List packages that the PACKAGE depends on" }, + { 'D', "depends", "List packages that the PACKAGE (directly) depends on" }, + { 'R', "rdepends", "List all packages (directly) depending on PACKAGE" }, + { 'r', NULL, "Synonym for -R (deprecated)" }, { 'P', "provides", "List virtual packages provided by PACKAGE" }, - { 'r', "rdepends", "List all packages depending on PACKAGE" }, { 0x10000, "replaces", "List packages whom files PACKAGE might replace" }, { 'i', "install-if", "List the PACKAGE's install_if rule" }, { 'I', "rinstall-if", "List all packages having install_if referencing PACKAGE" }, diff --git a/src/search.c b/src/search.c index ef3d254..e5044a9 100644 --- a/src/search.c +++ b/src/search.c @@ -88,6 +88,7 @@ static int search_parse(void *ctx, struct apk_db_options *dbopts, ictx->print_package = print_origin_name; break; case 'r': + case 'R': ictx->print_result = print_rdepends; break; default: @@ -172,7 +173,8 @@ static struct apk_option search_options[] = { { 'd', "description", "Search package descriptions (implies -a)" }, { 'e', "exact", "Require exact match (instead of substring match)" }, { 'o', "origin", "Print origin package name instead of the subpackage" }, - { 'r', "rdepends", "Print reverse dependencies of package" }, + { 'R', "rdepends", "Print reverse dependencies of package" }, + { 'r', NULL, "Synonym for -R (deprecated)" }, }; static struct apk_applet apk_search = { -- 1.8.3.1 --- Unsubscribe: alpine-devel+unsubscribe@lists.alpinelinux.org Help: alpine-devel+help@lists.alpinelinux.org ---