X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch.c;h=e98b14395ba8341db174d844b1ae873c04caa1b5;hp=ed087a070150e5d1771968a8833587010bc8efcf;hb=e58d85dd7589351955e220351bb68e777cfc0f88;hpb=491ece966fbc0e8bcd14f2db87b10a6af82814cc diff --git a/notmuch.c b/notmuch.c index ed087a07..e98b1439 100644 --- a/notmuch.c +++ b/notmuch.c @@ -81,6 +81,11 @@ print_formatted_seconds (double seconds) int hours; int minutes; + if (seconds < 1) { + printf ("almost no time"); + return; + } + if (seconds > 3600) { hours = (int) seconds / 3600; printf ("%dh ", hours); @@ -434,12 +439,22 @@ setup_command (int argc, char *argv[]) gettimeofday (&tv_now, NULL); elapsed = tv_elapsed (add_files_state.tv_start, tv_now); - printf ("Processed %d total files in ", add_files_state.processed_files); + printf ("Processed %d %s in ", add_files_state.processed_files, + add_files_state.processed_files == 1 ? + "file" : "total files"); print_formatted_seconds (elapsed); - printf (" (%d files/sec.). \n", - (int) (add_files_state.processed_files / elapsed)); - printf ("Added %d unique messages to the database.\n\n", - add_files_state.added_messages); + if (elapsed > 1) { + printf (" (%d files/sec.). \n", + (int) (add_files_state.processed_files / elapsed)); + } else { + printf (". \n"); + } + if (add_files_state.added_messages) { + printf ("Added %d %s to the database.\n\n", + add_files_state.added_messages, + add_files_state.added_messages == 1 ? + "message" : "unique messages"); + } printf ("When new mail is delivered to %s in the future,\n" "run \"notmuch new\" to add it to the database.\n", @@ -488,16 +503,24 @@ new_command (int argc, char *argv[]) elapsed = tv_elapsed (add_files_state.tv_start, tv_now); if (add_files_state.processed_files) { - printf ("Processed %d total files in ", add_files_state.processed_files); + printf ("Processed %d %s in ", add_files_state.processed_files, + add_files_state.processed_files == 1 ? + "file" : "total files"); print_formatted_seconds (elapsed); - printf (" (%d files/sec.). \n", - (int) (add_files_state.processed_files / elapsed)); + if (elapsed > 1) { + printf (" (%d files/sec.). \n", + (int) (add_files_state.processed_files / elapsed)); + } else { + printf (". \n"); + } } if (add_files_state.added_messages) { - printf ("Added %d new messages to the database (not much, really).\n", - add_files_state.added_messages); + printf ("Added %d new %s to the database (not much, really).\n", + add_files_state.added_messages, + add_files_state.added_messages == 1 ? + "message" : "messages"); } else { - printf ("No new mail---and that's not much!.\n"); + printf ("No new mail---and that's not much!\n"); } if (ret) {