1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-09 23:39:51 +02:00

* main.h, misc.c (parse_options): Add the ability to have help

strings in xxx-options commands.

* keyserver.c (keyserver_opts), import.c (parse_import_options),
export.c (parse_export_options), g10.c (parse_list_options, main):
Add help strings to xxx-options.
This commit is contained in:
David Shaw 2005-09-14 22:31:21 +00:00
parent 65566b5633
commit 4afa18bcaa
7 changed files with 130 additions and 63 deletions

View File

@ -1,3 +1,12 @@
2005-09-14 David Shaw <dshaw@jabberwocky.com>
* main.h, misc.c (parse_options): Add the ability to have help
strings in xxx-options commands.
* keyserver.c (keyserver_opts), import.c (parse_import_options),
export.c (parse_export_options), g10.c (parse_list_options, main):
Add help strings to xxx-options.
2005-09-10 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (show_names): Moved name display code out from

View File

@ -47,23 +47,30 @@ parse_export_options(char *str,unsigned int *options,int noisy)
{
struct parse_options export_opts[]=
{
{"export-local-sigs",EXPORT_LOCAL_SIGS,NULL},
{"export-attributes",EXPORT_ATTRIBUTES,NULL},
{"export-sensitive-revkeys",EXPORT_SENSITIVE_REVKEYS,NULL},
{"export-minimal",EXPORT_MINIMAL|EXPORT_CLEAN_SIGS|EXPORT_CLEAN_UIDS,NULL},
{"export-clean",EXPORT_CLEAN_SIGS|EXPORT_CLEAN_UIDS,NULL},
{"export-clean-sigs",EXPORT_CLEAN_SIGS,NULL},
{"export-clean-uids",EXPORT_CLEAN_UIDS,NULL},
{"export-reset-subkey-passwd", EXPORT_RESET_SUBKEY_PASSWD, NULL},
{"export-local-sigs",EXPORT_LOCAL_SIGS,NULL,
N_("export signatures that are marked as local-only")},
{"export-attributes",EXPORT_ATTRIBUTES,NULL,
N_("export attribute user IDs (generally photo IDs)")},
{"export-sensitive-revkeys",EXPORT_SENSITIVE_REVKEYS,NULL,
N_("export revocation keys that are marked as \"sensitive\"")},
{"export-clean-sigs",EXPORT_CLEAN_SIGS,NULL,
N_("remove unusable signatures during export")},
{"export-clean-uids",EXPORT_CLEAN_UIDS,NULL,
N_("remove unusable user IDs during export")},
{"export-clean",EXPORT_CLEAN_SIGS|EXPORT_CLEAN_UIDS,NULL,
N_("all export-clean-* options from above")},
{"export-minimal",
EXPORT_MINIMAL|EXPORT_CLEAN_SIGS|EXPORT_CLEAN_UIDS,NULL,
N_("export the smallest key possible")},
{"export-reset-subkey-passwd",EXPORT_RESET_SUBKEY_PASSWD,NULL,
N_("remove the passphrase from exported subkeys")},
/* Aliases for backward compatibility */
{"include-local-sigs",EXPORT_LOCAL_SIGS,NULL},
{"include-attributes",EXPORT_ATTRIBUTES,NULL},
{"include-sensitive-revkeys",EXPORT_SENSITIVE_REVKEYS,NULL},
{"include-local-sigs",EXPORT_LOCAL_SIGS,NULL,NULL},
{"include-attributes",EXPORT_ATTRIBUTES,NULL,NULL},
{"include-sensitive-revkeys",EXPORT_SENSITIVE_REVKEYS,NULL,NULL},
/* dummy */
{"export-unusable-sigs",0,NULL},
{NULL,0,NULL}
{"export-unusable-sigs",0,NULL,NULL},
{NULL,0,NULL,NULL}
/* add tags for include revoked and disabled? */
};

View File

@ -1504,20 +1504,33 @@ parse_list_options(char *str)
char *subpackets=""; /* something that isn't NULL */
struct parse_options lopts[]=
{
{"show-photos",LIST_SHOW_PHOTOS,NULL},
{"show-policy-urls",LIST_SHOW_POLICY_URLS,NULL},
{"show-notations",LIST_SHOW_NOTATIONS,NULL},
{"show-std-notations",LIST_SHOW_STD_NOTATIONS,NULL},
{"show-standard-notations",LIST_SHOW_STD_NOTATIONS,NULL},
{"show-user-notations",LIST_SHOW_USER_NOTATIONS,NULL},
{"show-keyserver-urls",LIST_SHOW_KEYSERVER_URLS,NULL},
{"show-uid-validity",LIST_SHOW_UID_VALIDITY,NULL},
{"show-unusable-uids",LIST_SHOW_UNUSABLE_UIDS,NULL},
{"show-unusable-subkeys",LIST_SHOW_UNUSABLE_SUBKEYS,NULL},
{"show-keyring",LIST_SHOW_KEYRING,NULL},
{"show-sig-expire",LIST_SHOW_SIG_EXPIRE,NULL},
{"show-sig-subpackets",LIST_SHOW_SIG_SUBPACKETS,NULL},
{NULL,0,NULL}
{"show-photos",LIST_SHOW_PHOTOS,NULL,
N_("display photo IDs during key listings")},
{"show-policy-urls",LIST_SHOW_POLICY_URLS,NULL,
N_("show policy URLs during signature listings")},
{"show-notations",LIST_SHOW_NOTATIONS,NULL,
N_("show all notations during signature listings")},
{"show-std-notations",LIST_SHOW_STD_NOTATIONS,NULL,
N_("show IETF standard notations during signature listings")},
{"show-standard-notations",LIST_SHOW_STD_NOTATIONS,NULL,
NULL},
{"show-user-notations",LIST_SHOW_USER_NOTATIONS,NULL,
N_("show user-supplied notations during signature listings")},
{"show-keyserver-urls",LIST_SHOW_KEYSERVER_URLS,NULL,
N_("show preferred keyserver URLs during signature listings")},
{"show-uid-validity",LIST_SHOW_UID_VALIDITY,NULL,
N_("show user ID validity during key listings")},
{"show-unusable-uids",LIST_SHOW_UNUSABLE_UIDS,NULL,
N_("show revoked and expired user IDs in key listings")},
{"show-unusable-subkeys",LIST_SHOW_UNUSABLE_SUBKEYS,NULL,
N_("show revoked and expired subkeys in key listings")},
{"show-keyring",LIST_SHOW_KEYRING,NULL,
N_("show the keyring name in key listings")},
{"show-sig-expire",LIST_SHOW_SIG_EXPIRE,NULL,
N_("show expiration dates during signature listings")},
{"show-sig-subpackets",LIST_SHOW_SIG_SUBPACKETS,NULL,
NULL},
{NULL,0,NULL,NULL}
};
/* C99 allows for non-constant initializers, but we'd like to
@ -2396,16 +2409,25 @@ main (int argc, char **argv )
{
struct parse_options vopts[]=
{
{"show-photos",VERIFY_SHOW_PHOTOS,NULL},
{"show-policy-urls",VERIFY_SHOW_POLICY_URLS,NULL},
{"show-notations",VERIFY_SHOW_NOTATIONS,NULL},
{"show-std-notations",VERIFY_SHOW_STD_NOTATIONS,NULL},
{"show-standard-notations",VERIFY_SHOW_STD_NOTATIONS,NULL},
{"show-user-notations",VERIFY_SHOW_USER_NOTATIONS,NULL},
{"show-keyserver-urls",VERIFY_SHOW_KEYSERVER_URLS,NULL},
{"show-uid-validity",VERIFY_SHOW_UID_VALIDITY,NULL},
{"show-unusable-uids",VERIFY_SHOW_UNUSABLE_UIDS,NULL},
{NULL,0,NULL}
{"show-photos",VERIFY_SHOW_PHOTOS,NULL,
N_("display photo IDs during signature verification")},
{"show-policy-urls",VERIFY_SHOW_POLICY_URLS,NULL,
N_("show policy URLs during signature verification")},
{"show-notations",VERIFY_SHOW_NOTATIONS,NULL,
N_("show all notations during signature verification")},
{"show-std-notations",VERIFY_SHOW_STD_NOTATIONS,NULL,
N_("show IETF standard notations during signature verification")},
{"show-standard-notations",VERIFY_SHOW_STD_NOTATIONS,NULL,
NULL},
{"show-user-notations",VERIFY_SHOW_USER_NOTATIONS,NULL,
N_("show user-supplied notations during signature verification")},
{"show-keyserver-urls",VERIFY_SHOW_KEYSERVER_URLS,NULL,
N_("show preferred keyserver URLs during signature verification")},
{"show-uid-validity",VERIFY_SHOW_UID_VALIDITY,NULL,
N_("show user ID validity during signature verification")},
{"show-unusable-uids",VERIFY_SHOW_UNUSABLE_UIDS,NULL,
N_("show revoked and expired user IDs in signature verification")},
{NULL,0,NULL,NULL}
};
if(!parse_options(pargs.r.ret_str,&opt.verify_options,vopts,1))

View File

@ -91,20 +91,28 @@ parse_import_options(char *str,unsigned int *options,int noisy)
{
struct parse_options import_opts[]=
{
{"import-local-sigs",IMPORT_LOCAL_SIGS,NULL},
{"repair-pks-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG,NULL},
{"fast-import",IMPORT_FAST,NULL},
{"convert-sk-to-pk",IMPORT_SK2PK,NULL},
{"merge-only",IMPORT_MERGE_ONLY,NULL},
{"import-clean",IMPORT_CLEAN_SIGS|IMPORT_CLEAN_UIDS,NULL},
{"import-clean-sigs",IMPORT_CLEAN_SIGS,NULL},
{"import-clean-uids",IMPORT_CLEAN_UIDS,NULL},
{"import-local-sigs",IMPORT_LOCAL_SIGS,NULL,
N_("import signatures that are marked as local-only")},
{"repair-pks-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG,NULL,
N_("repair damage from the pks keyserver during import")},
{"fast-import",IMPORT_FAST,NULL,
N_("do not update the trustdb after import")},
{"convert-sk-to-pk",IMPORT_SK2PK,NULL,
N_("create a public key when importing a secret key")},
{"merge-only",IMPORT_MERGE_ONLY,NULL,
N_("only accept updates to existing keys")},
{"import-clean-sigs",IMPORT_CLEAN_SIGS,NULL,
N_("remove unusable signatures after import")},
{"import-clean-uids",IMPORT_CLEAN_UIDS,NULL,
N_("remove unusable user IDs after import")},
{"import-clean",IMPORT_CLEAN_SIGS|IMPORT_CLEAN_UIDS,NULL,
N_("all import-clean-* options from above")},
/* Aliases for backward compatibility */
{"allow-local-sigs",IMPORT_LOCAL_SIGS,NULL},
{"repair-hkp-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG,NULL},
{"allow-local-sigs",IMPORT_LOCAL_SIGS,NULL,NULL},
{"repair-hkp-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG,NULL,NULL},
/* dummy */
{"import-unusable-sigs",0,NULL},
{NULL,0,NULL}
{"import-unusable-sigs",0,NULL,NULL},
{NULL,0,NULL,NULL}
};
return parse_options(str,options,import_opts,noisy);

View File

@ -74,15 +74,26 @@ struct keyrec
static struct parse_options keyserver_opts[]=
{
{"include-revoked",KEYSERVER_INCLUDE_REVOKED,NULL},
{"include-subkeys",KEYSERVER_INCLUDE_SUBKEYS,NULL},
{"keep-temp-files",KEYSERVER_KEEP_TEMP_FILES,NULL},
{"refresh-add-fake-v3-keyids",KEYSERVER_ADD_FAKE_V3,NULL},
{"auto-key-retrieve",KEYSERVER_AUTO_KEY_RETRIEVE,NULL},
{"auto-pka-retrieve",KEYSERVER_AUTO_PKA_RETRIEVE,NULL},
{"try-dns-srv",KEYSERVER_TRY_DNS_SRV,NULL},
{"honor-keyserver-url",KEYSERVER_HONOR_KEYSERVER_URL,NULL},
{NULL,0,NULL}
{"include-revoked",KEYSERVER_INCLUDE_REVOKED,NULL,
N_("include revoked keys in search results")},
{"include-subkeys",KEYSERVER_INCLUDE_SUBKEYS,NULL,
N_("include subkeys when searching by key ID")},
/* not a real option - just for the help message */
{"use-temp-files",0,NULL,
N_("use temporary files to pass data to keyserver helpers")},
{"keep-temp-files",KEYSERVER_KEEP_TEMP_FILES,NULL,
N_("do not delete temporary files after using them")},
{"refresh-add-fake-v3-keyids",KEYSERVER_ADD_FAKE_V3,NULL,
NULL},
{"auto-key-retrieve",KEYSERVER_AUTO_KEY_RETRIEVE,NULL,
N_("automatically retrieve keys when verifying signatures")},
{"auto-pka-retrieve",KEYSERVER_AUTO_PKA_RETRIEVE,NULL,
NULL},
{"try-dns-srv",KEYSERVER_TRY_DNS_SRV,NULL,
NULL},
{"honor-keyserver-url",KEYSERVER_HONOR_KEYSERVER_URL,NULL,
N_("honor the preferred keyserver URL set on the key")},
{NULL,0,NULL,NULL}
};
static int keyserver_work(int action,STRLIST list,KEYDB_SEARCH_DESC *desc,

View File

@ -118,6 +118,7 @@ struct parse_options
char *name;
unsigned int bit;
char **value;
char *help;
};
char *optsep(char **stringp);

View File

@ -968,11 +968,20 @@ parse_options(char *str,unsigned int *options,
if (str && !strcmp (str, "help"))
{
int i;
int i,maxlen=0;
/* Figure out the longest option name so we can line these up
neatly. */
for(i=0;opts[i].name;i++)
if(opts[i].help && maxlen<strlen(opts[i].name))
maxlen=strlen(opts[i].name);
for(i=0;opts[i].name;i++)
printf ("%s\n", opts[i].name);
g10_exit (0);
if(opts[i].help)
printf("%s%*s%s\n",opts[i].name,
maxlen+2-strlen(opts[i].name),"",_(opts[i].help));
g10_exit(0);
}
while((tok=optsep(&str)))