From: Uwe Hermann Date: Sat, 3 Jun 2017 15:03:44 +0000 (+0200) Subject: List supported devices, modules, decoders via --list-supported. X-Git-Tag: sigrok-cli-0.7.0~9 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6293db8aea090170eced25d6f92c348b013ea475;p=sigrok-cli.git List supported devices, modules, decoders via --list-supported. Move this data from -V to -L|--list-supported for usability reasons. This fixes bug #604. --- diff --git a/doc/sigrok-cli.1 b/doc/sigrok-cli.1 index 545b4d5..1666f89 100644 --- a/doc/sigrok-cli.1 +++ b/doc/sigrok-cli.1 @@ -22,7 +22,10 @@ Show a help text and exit. .B "\-V, \-\-version" Show .B sigrok-cli -version, and information about supported hardware drivers, input file +version and the versions of libraries used. +.TP +.B "\-L, \-\-list-supported" +Show information about supported hardware drivers, input file formats, output file formats, and protocol decoders. .TP \fB\-d, \-\-driver\fP diff --git a/main.c b/main.c index 94f1c0f..e4d321b 100644 --- a/main.c +++ b/main.c @@ -241,6 +241,8 @@ int main(int argc, char **argv) if (opt_version) show_version(); + else if (opt_list_supported) + show_supported(); else if (opt_input_format && opt_show) show_input(); else if (opt_output_format && opt_show) diff --git a/options.c b/options.c index 9c8dc8c..ca16e4c 100644 --- a/options.c +++ b/options.c @@ -22,6 +22,7 @@ #include "sigrok-cli.h" gboolean opt_version = FALSE; +gboolean opt_list_supported = FALSE; gint opt_loglevel = SR_LOG_WARN; /* Show errors+warnings by default. */ gboolean opt_scan_devs = FALSE; gboolean opt_wait_trigger = FALSE; @@ -97,7 +98,9 @@ static gchar **output_file_array = NULL; static const GOptionEntry optargs[] = { {"version", 'V', 0, G_OPTION_ARG_NONE, &opt_version, - "Show version and support list", NULL}, + "Show version", NULL}, + {"list-supported", 'L', 0, G_OPTION_ARG_NONE, &opt_list_supported, + "List supported devices/modules/decoders", NULL}, {"loglevel", 'l', 0, G_OPTION_ARG_INT, &opt_loglevel, "Set loglevel (5 is most verbose)", NULL}, {"driver", 'd', 0, G_OPTION_ARG_CALLBACK, &check_opt_drv, diff --git a/show.c b/show.c index 62a1ac4..1c5aad0 100644 --- a/show.c +++ b/show.c @@ -57,6 +57,18 @@ static gint sort_pds(gconstpointer a, gconstpointer b) #endif void show_version(void) +{ + printf("sigrok-cli %s\n\n", SC_PACKAGE_VERSION_STRING); + + printf("Using libsigrok %s (lib version %s).\n", + sr_package_version_string_get(), sr_lib_version_string_get()); +#ifdef HAVE_SRD + printf("Using libsigrokdecode %s (lib version %s).\n\n", + srd_package_version_string_get(), srd_lib_version_string_get()); +#endif +} + +void show_supported(void) { struct sr_dev_driver **drivers, *driver; const struct sr_input_module **inputs, *input; @@ -69,15 +81,6 @@ void show_version(void) struct srd_decoder *dec; #endif - printf("sigrok-cli %s\n\n", SC_PACKAGE_VERSION_STRING); - - printf("Using libsigrok %s (lib version %s).\n", - sr_package_version_string_get(), sr_lib_version_string_get()); -#ifdef HAVE_SRD - printf("Using libsigrokdecode %s (lib version %s).\n\n", - srd_package_version_string_get(), srd_lib_version_string_get()); -#endif - printf("Supported hardware drivers:\n"); drivers = sr_driver_list(sr_ctx); for (sl = NULL, i = 0; drivers[i]; i++) diff --git a/sigrok-cli.h b/sigrok-cli.h index d0b5872..96d8128 100644 --- a/sigrok-cli.h +++ b/sigrok-cli.h @@ -48,6 +48,7 @@ int maybe_config_list(struct sr_dev_driver *driver, /* show.c */ void show_version(void); +void show_supported(void); void show_dev_list(void); void show_dev_detail(void); void show_pd_detail(void); @@ -99,6 +100,7 @@ void clear_anykey(void); /* options.c */ extern gboolean opt_version; +extern gboolean opt_list_supported; extern gint opt_loglevel; extern gboolean opt_scan_devs; extern gboolean opt_wait_trigger;