From 5c3b1f0c49d9a53aa8e6c907e140c2dca50b0c0e Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Thu, 5 May 2011 15:17:09 +0200 Subject: silent asciidoc generation Signed-off-by: Nikola Pajkovsky --- src/cli/Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/cli') diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am index a7597ad6..f757a19c 100644 --- a/src/cli/Makefile.am +++ b/src/cli/Makefile.am @@ -1,3 +1,5 @@ +-include ../../config.mak + bin_PROGRAMS = \ abrt-handle-crashdump \ abrt-cli @@ -51,7 +53,7 @@ man1_MANS = ${MAN_TXT:%.txt=%.1} xmlto man $< %.xml: %.txt ../../asciidoc.conf - asciidoc --backend=docbook --doctype=manpage --conf-file ../../asciidoc.conf -aabrt_version=$(PACKAGE_VERSION) -o $@ $< + $(ASCIIDOC_SILENT) asciidoc --backend=docbook --doctype=manpage --conf-file ../../asciidoc.conf -aabrt_version=$(PACKAGE_VERSION) -o $@ $< CLEANFILES = $(man1_MANS) -- cgit From c2095ab91d0b2047c2340309b939f05f184b7a8b Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Thu, 5 May 2011 15:47:44 +0200 Subject: silent xmlto generation Signed-off-by: Nikola Pajkovsky --- src/cli/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/cli') diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am index f757a19c..fa28a2bb 100644 --- a/src/cli/Makefile.am +++ b/src/cli/Makefile.am @@ -50,7 +50,7 @@ MAN_TXT = \ man1_MANS = ${MAN_TXT:%.txt=%.1} %.1 %.5 %.7: %.xml - xmlto man $< + $(XMLTO_SILENT) xmlto man $< > /dev/null 2>&1 %.xml: %.txt ../../asciidoc.conf $(ASCIIDOC_SILENT) asciidoc --backend=docbook --doctype=manpage --conf-file ../../asciidoc.conf -aabrt_version=$(PACKAGE_VERSION) -o $@ $< -- cgit From fb0cd889c011a128a8d03ebeb52f43cd44f5b40e Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Fri, 15 Apr 2011 17:30:31 +0200 Subject: abrt-cli: select reporters by numbers (trac#194) --- src/cli/report.c | 58 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 15 deletions(-) (limited to 'src/cli') diff --git a/src/cli/report.c b/src/cli/report.c index 96bf0062..72e9c4a6 100644 --- a/src/cli/report.c +++ b/src/cli/report.c @@ -422,6 +422,31 @@ static bool set_echo(bool enable) return true; } +/* Returns true if the string contains the specified number. */ +static bool is_number_in_string(unsigned number, const char *str) +{ + const char *c; + char numstr[sizeof(int) * 3 + 2]; + int len; + + len = snprintf(numstr, sizeof(numstr), "%u", number); + for (c = str; *c; c++) + { + c = strstr(c, numstr); + if (!c) + /* no such number exists in the string */ + return false; + if ((c == str || !isalnum(c[-1])) && !isalnum(c[len])) + /* found */ + return true; + + /* found, but it's part of another number. Continue + * from the next position. */ + } + + return false; +} + /** * Asks user for missing information */ @@ -744,30 +769,33 @@ int report(const char *dump_dir_name, int flags) else { const char *rating_str = get_problem_item_content_or_NULL(problem_data, FILENAME_RATING); - unsigned rating = rating_str ? xatou(rating_str) : 4; + unsigned i, rating = rating_str ? xatou(rating_str) : 4; + GList *li; + char wanted_reporters[255]; - /* For every reporter, ask if user really wants to report using it. */ - for (GList *li = report_events; li; li = li->next) + puts(_("How would you like to report the problem?")); + /* Print list of reporters and ask the user which should be used. */ + for (li = report_events, i = 1; li; li = li->next, i++) { char *reporter_name = (char *) li->data; event_config_t *config = get_event_config(reporter_name); - char question[255]; - char *show_reporter_name; - if (config) - show_reporter_name = (config->screen_name) ? config->screen_name : reporter_name; - else - show_reporter_name = reporter_name; - snprintf(question, sizeof(question), _("Report using %s?"), show_reporter_name); + printf(" %d) %s\n", i, (config && config->screen_name) ? config->screen_name : reporter_name); + } + + read_from_stdin(_("Select reporter(s): "), wanted_reporters, sizeof(wanted_reporters)); + + for (li = report_events, i = 1; li; li = li->next, i++) + { + char *reporter_name = (char *) li->data; + event_config_t *config = get_event_config(reporter_name); if (!config) VERB1 log("No configuration file found for '%s' reporter", reporter_name); - - if (!ask_yesno(question)) - { - puts(_("Skipping...")); + + /* Was this reporter requested? */ + if (!is_number_in_string(i, wanted_reporters)) continue; - } /* TODO: npajkovs; not implemented yet */ //const char *rating_required = get_map_string_item_or_NULL(single_plugin_settings, "RatingRequired"); -- cgit From afa3ecbd33fe6a6d13255255076ecc1ba90a9926 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Tue, 19 Apr 2011 15:52:34 +0200 Subject: abrt-cli: fix crash when only one analyzer is available --- src/cli/report.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/cli') diff --git a/src/cli/report.c b/src/cli/report.c index 72e9c4a6..989fb0f5 100644 --- a/src/cli/report.c +++ b/src/cli/report.c @@ -611,7 +611,7 @@ char *select_event_option(GList *list_options) unsigned count = g_list_length(list_options) - 1; if (!count) - return NULL; + return xstrdup((char*)list_options->data); int pos = -1; fprintf(stdout, _("Select how you would like to analyze the problem:\n")); -- cgit From 0159b489446bada0a8c8bbbabef9a443b4a21fe1 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Tue, 19 Apr 2011 16:07:47 +0200 Subject: abrt-cli: improve analyzer selection dialog --- src/cli/report.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/cli') diff --git a/src/cli/report.c b/src/cli/report.c index 989fb0f5..93d1abd9 100644 --- a/src/cli/report.c +++ b/src/cli/report.c @@ -609,12 +609,12 @@ char *select_event_option(GList *list_options) if (!list_options) return NULL; - unsigned count = g_list_length(list_options) - 1; - if (!count) + unsigned count = g_list_length(list_options); + if (count == 1) return xstrdup((char*)list_options->data); - int pos = -1; - fprintf(stdout, _("Select how you would like to analyze the problem:\n")); + int pos = 0; + fprintf(stdout, _("How you would like to analyze the problem?\n")); for (GList *li = list_options; li; li = li->next) { char *opt = (char*)li->data; @@ -630,14 +630,9 @@ char *select_event_option(GList *list_options) unsigned ii; for (ii = 0; ii < 3; ++ii) { - fprintf(stdout, _("Choose option [0 - %u]: "), count); - fflush(NULL); - char answer[16]; - if (!fgets(answer, sizeof(answer), stdin)) - continue; - answer[strlen(answer) - 1] = '\0'; + read_from_stdin(_("Select analyzer: "), answer, sizeof(answer)); if (!*answer) continue; @@ -645,6 +640,7 @@ char *select_event_option(GList *list_options) if (picked > count) { fprintf(stdout, _("You have chosen number out of range")); + fprintf(stdout, "\n"); continue; } @@ -654,7 +650,7 @@ char *select_event_option(GList *list_options) if (ii == 3) error_msg_and_die(_("Invalid input, program exiting...")); - GList *choosen = g_list_nth(list_options, picked); + GList *choosen = g_list_nth(list_options, picked - 1); return xstrdup((char*)choosen->data); } -- cgit