diff options
author | Leandro Pereira <leandro@hardinfo.org> | 2021-04-03 16:05:30 -0700 |
---|---|---|
committer | Leandro Pereira <leandro@hardinfo.org> | 2021-04-03 16:05:30 -0700 |
commit | 5ddf73edf0822f22aa091325b89d286161ad3340 (patch) | |
tree | 3639489b55879f3b7dccfbfbf1fb8a0208276ab7 | |
parent | b937065c4ffefcf026cdd5f90c040752199eb780 (diff) |
Add command-line parameter to quieten HardInfo when in non-GUI mode
-rw-r--r-- | hardinfo/util.c | 8 | ||||
-rw-r--r-- | includes/hardinfo.h | 1 | ||||
-rw-r--r-- | shell/report.c | 4 | ||||
-rw-r--r-- | shell/shell.c | 6 |
4 files changed, 14 insertions, 5 deletions
diff --git a/hardinfo/util.c b/hardinfo/util.c index 4a27299a..ec91565a 100644 --- a/hardinfo/util.c +++ b/hardinfo/util.c @@ -390,6 +390,7 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param) static gboolean autoload_deps = FALSE; static gboolean run_xmlrpc_server = FALSE; static gboolean skip_benchmarks = FALSE; + static gboolean quiet = FALSE; static gchar *report_format = NULL; static gchar *run_benchmark = NULL; static gchar *result_format = NULL; @@ -399,6 +400,12 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param) static GOptionEntry options[] = { { + .long_name = "quiet", + .short_name = 'q', + .arg = G_OPTION_ARG_NONE, + .arg_data = &quiet, + .description = N_("do not print status messages to standard output")}, + { .long_name = "generate-report", .short_name = 'r', .arg = G_OPTION_ARG_NONE, @@ -509,6 +516,7 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param) param->run_xmlrpc_server = run_xmlrpc_server; param->skip_benchmarks = skip_benchmarks; param->force_all_details = force_all_details; + param->quiet = quiet; param->argv0 = *(argv)[0]; if (report_format) { diff --git a/includes/hardinfo.h b/includes/hardinfo.h index e2a3ec7e..57a943bf 100644 --- a/includes/hardinfo.h +++ b/includes/hardinfo.h @@ -58,6 +58,7 @@ struct _ProgramParameters { gboolean autoload_deps; gboolean run_xmlrpc_server; gboolean skip_benchmarks; + gboolean quiet; /* * OK to use the common parts of HTML(4.0) and Pango Markup diff --git a/shell/report.c b/shell/report.c index ccd75c99..d77a6dca 100644 --- a/shell/report.c +++ b/shell/report.c @@ -723,7 +723,7 @@ report_create_inner_from_module_list(ReportContext * ctx, GSList * modules) ShellModule *module = (ShellModule *) modules->data; GSList *entries; - if (!params.gui_running) + if (!params.gui_running && !params.quiet) fprintf(stderr, "\033[40;32m%s\033[0m\n", module->name); report_title(ctx, module->name); @@ -732,7 +732,7 @@ report_create_inner_from_module_list(ReportContext * ctx, GSList * modules) ShellModuleEntry *entry = (ShellModuleEntry *) entries->data; if (entry->flags & MODULE_FLAG_HIDE) continue; - if (!params.gui_running) + if (!params.gui_running && !params.quiet) fprintf(stderr, "\033[2K\033[40;32;1m %s\033[0m\n", entry->name); diff --git a/shell/shell.c b/shell/shell.c index bfa5dc8c..1de2a661 100644 --- a/shell/shell.c +++ b/shell/shell.c @@ -245,7 +245,7 @@ void shell_status_pulse(void) gtk_progress_bar_pulse(GTK_PROGRESS_BAR(shell->progress)); while (gtk_events_pending()) gtk_main_iteration(); - } else { + } else if (!params.quiet) { static gint counter = 0; fprintf(stderr, "\033[2K\033[40;37;1m %c\033[0m\r", @@ -260,7 +260,7 @@ void shell_status_set_percentage(gint percentage) (float) percentage / 100.0); while (gtk_events_pending()) gtk_main_iteration(); - } else { + } else if (!params.quiet) { if (percentage < 1 || percentage >= 100) { fprintf(stderr, "\033[2K"); } else { @@ -336,7 +336,7 @@ void shell_status_update(const gchar * message) gtk_progress_bar_pulse(GTK_PROGRESS_BAR(shell->progress)); while (gtk_events_pending()) gtk_main_iteration(); - } else { + } else if (!params.quiet) { fprintf(stderr, "\033[2K\033[40;37;1m %s\033[0m\r", message); } } |