diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-02-23 07:43:33 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-02-23 07:43:33 +0100 |
commit | 2df1f3eff0e81ec3446ddac750ce88da83258cce (patch) | |
tree | 0a3e72b8389b85f92e6dc5932d9463a83f963dc9 /src/CLI/CLI.cpp | |
parent | eae3199e4adc0e92a65f48293b1369c1d8c375bc (diff) | |
download | abrt-2df1f3eff0e81ec3446ddac750ce88da83258cce.tar.gz abrt-2df1f3eff0e81ec3446ddac750ce88da83258cce.tar.xz abrt-2df1f3eff0e81ec3446ddac750ce88da83258cce.zip |
cli: add support for "--report @N" and "--report PARTIAL_UUID"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src/CLI/CLI.cpp')
-rw-r--r-- | src/CLI/CLI.cpp | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/CLI/CLI.cpp b/src/CLI/CLI.cpp index a8786e99..ef88732f 100644 --- a/src/CLI/CLI.cpp +++ b/src/CLI/CLI.cpp @@ -128,7 +128,7 @@ static void usage(char *argv0) int main(int argc, char** argv) { - char* uuid = NULL; + const char* uuid = NULL; int op = -1; setlocale(LC_ALL, ""); @@ -194,10 +194,39 @@ int main(int argc, char** argv) break; } case OPT_REPORT: - exitcode = report(uuid, false); - break; case OPT_REPORT_ALWAYS: - exitcode = report(uuid, true); + exitcode = report(uuid, op == OPT_REPORT_ALWAYS); + if (exitcode == -1) /* no such UUID */ + { + vector_map_crash_data_t ci = call_GetCrashInfos(); + unsigned num_crashinfos = ci.size(); + if (uuid[0] == '@') /* "--report @N" syntax */ + { + unsigned position = xatoi_u(uuid + 1); + if (position >= num_crashinfos) + error_msg_and_die("There are only %u crash infos", num_crashinfos); + map_crash_data_t& info = ci[position]; + uuid = get_crash_data_item_content(info, CD_UUID).c_str(); + } else { + unsigned uuid_len = strlen(uuid); + unsigned ii; + for (ii = 0; ii < num_crashinfos; ii++) + { + map_crash_data_t& info = ci[ii]; + const char *this_uuid = get_crash_data_item_content(info, CD_UUID).c_str(); + if (strncmp(uuid, this_uuid, uuid_len) == 0) + { + uuid = this_uuid; + goto do_report; + } + } + error_msg_and_die("Crash '%s' not found", uuid); + } + do_report: + exitcode = report(uuid, op == OPT_REPORT_ALWAYS); + if (exitcode == -1) + error_msg_and_die("Crash '%s' not found", uuid); + } break; case OPT_DELETE: { |