If --device-type is given without a type, list the available types.

This commit is contained in:
Oliver Jowett 2020-08-05 20:12:06 +08:00
parent 2fa793d0d7
commit ce5cf89e60
1 changed files with 11 additions and 8 deletions

7
sdr.c
View File

@ -127,7 +127,8 @@ void sdrShowHelp()
bool sdrHandleOption(int argc, char **argv, int *jptr) bool sdrHandleOption(int argc, char **argv, int *jptr)
{ {
int j = *jptr; int j = *jptr;
if (!strcmp(argv[j], "--device-type") && (j+1) < argc) { if (!strcmp(argv[j], "--device-type")) {
if ((j+1) < argc) {
++j; ++j;
for (int i = 0; sdr_handlers[i].name; ++i) { for (int i = 0; sdr_handlers[i].name; ++i) {
if (!strcasecmp(sdr_handlers[i].name, argv[j])) { if (!strcasecmp(sdr_handlers[i].name, argv[j])) {
@ -136,8 +137,10 @@ bool sdrHandleOption(int argc, char **argv, int *jptr)
return true; return true;
} }
} }
fprintf(stderr, "SDR type '%s' not recognized. ", argv[j]);
}
fprintf(stderr, "SDR type '%s' not recognized; supported SDR types are:\n", argv[j]); fprintf(stderr, "Supported SDR types:\n");
for (int i = 0; sdr_handlers[i].name; ++i) { for (int i = 0; sdr_handlers[i].name; ++i) {
fprintf(stderr, " %s\n", sdr_handlers[i].name); fprintf(stderr, " %s\n", sdr_handlers[i].name);
} }