opensc-explorer: make '--card-driver ?' list all available drivers

Make opensc-explorer a bit more user friendly by treating the question mark
given as argument to option '--card-driver' special: list all available
drivers instead of stupidly bailing out.
This commit is contained in:
Peter Marschall 2019-12-25 19:12:31 +01:00
parent a40cde2d04
commit 5da40bf027
2 changed files with 12 additions and 3 deletions

View File

@ -55,8 +55,11 @@
<option>-c</option> <replaceable>driver</replaceable>
</term>
<listitem><para>
Use the given card driver. The default is
auto-detected.
Use the given card driver.
The default is to auto-detect the correct card driver.
The literal value <literal>?</literal> lists
all available card drivers and terminates
<command>opensc-explorer</command>.
</para></listitem>
</varlistentry>
<varlistentry>

View File

@ -76,7 +76,7 @@ static const struct option options[] = {
};
static const char *option_help[] = {
"Uses reader number <arg> [0]",
"Forces the use of driver <arg> [auto-detect]",
"Forces the use of driver <arg> [auto-detect; '?' for list]",
"Selects path <arg> on start-up, or none if empty [3F00]",
"Wait for card insertion",
"Verbose operation. Use several times to enable debug output.",
@ -2152,6 +2152,12 @@ int main(int argc, char *argv[])
}
if (opt_driver != NULL) {
/* special card driver value "?" means: list available drivers */
if (strncmp("?", opt_driver, sizeof("?")) == 0) {
err = util_list_card_drivers(ctx);
goto end;
}
err = sc_set_card_driver(ctx, opt_driver);
if (err) {
fprintf(stderr, "Driver '%s' not found!\n", opt_driver);