X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch.c;h=c47e64036786afbb19a834c49cc6aedffec7a5f2;hp=c3f0856fc58c4f662c7bfd23afcb8963308a94be;hb=f970d8078cc29f876bebe02937307a5a8f2d394f;hpb=305e76bc0ab2e7f3bd1ff2580e8d5dac8b4a7164 diff --git a/notmuch.c b/notmuch.c index c3f0856f..c47e6403 100644 --- a/notmuch.c +++ b/notmuch.c @@ -206,52 +206,67 @@ notmuch_help_command (unused (void *ctx), int argc, char *argv[]) } /* Handle the case of "notmuch" being invoked with no command - * argument. Print a welcome and explanatory message, then invoke - * notmuch_setup_command. + * argument. For now we just call notmuch_setup_command, but we plan + * to be more clever about this in the future. */ static int notmuch (void *ctx) { - int ret; + notmuch_config_t *config; + notmuch_bool_t is_new; + char *db_path; + struct stat st; - printf ( -"Welcome to notmuch!\n\n" + config = notmuch_config_open (ctx, NULL, &is_new); -"The goal of notmuch is to help you manage and search your collection of\n" -"email, and to efficiently keep up with the flow of email as it comes in.\n\n" - -"Notmuch needs to know a few things about you such as your name and email\n" -"address, as well as the directory that contains your email. This is where\n" -"you already have mail stored and where messages will be delivered in the\n" -"future. This directory can contain any number of sub-directories. Regular\n" -"files in these directories should be individual email messages. If there\n" -"are other, non-email files (such as indexes maintained by other email\n" -"programs) then notmuch will do its best to detect those and ignore them.\n\n" - -"If you already have your email being delivered to directories in either\n" -"maildir or mh format, then that's perfect. Mail storage that uses mbox\n" -"format, (where one mbox file contains many messages), will not work with\n" -"notmuch. If that's how your mail is currently stored, we recommend you\n" -"first convert it to maildir format with a utility such as mb2md. You can\n" -"continue configuring notmuch now, but be sure to complete the conversion\n" -"before you run \"notmuch new\" for the first time.\n\n"); + /* If the user has never configured notmuch, then run + * notmuch_setup_command which will give a nice welcome message, + * and interactively guide the user through the configuration. */ + if (is_new) { + notmuch_config_close (config); + return notmuch_setup_command (ctx, 0, NULL); + } - ret = notmuch_setup_command (ctx, 0, NULL); + /* Notmuch is already configured, but is there a database? */ + db_path = talloc_asprintf (ctx, "%s/%s", + notmuch_config_get_database_path (config), + ".notmuch"); + if (stat (db_path, &st)) { + notmuch_config_close (config); + if (errno != ENOENT) { + fprintf (stderr, "Error looking for notmuch database at %s: %s\n", + db_path, strerror (errno)); + return 1; + } + printf ("Notmuch is configured, but there's not yet a database at\n\n\t%s\n\n", + db_path); + printf ("You probably want to run \"notmuch new\" now to create that database.\n\n" + "Note that the first run of \"notmuch new\" can take a very long time\n" + "and that the resulting database will use roughly the same amount of\n" + "storage space as the email being indexed.\n\n"); + return 0; + } - printf ("\n" -"Notmuch is now configured, and the configuration settings are saved in\n" -"a file in your home directory named .notmuch-config . If you'd like to\n" -"change the configuration in the future, you can either edit that file\n" -"directly or run \"notmuch setup\".\n\n" + printf ("Notmuch is configured and appears to have a database. Excellent!\n\n" + "At this point you can start exploring the functionality of notmuch by\n" + "using commands such as:\n\n" + "\tnotmuch search tag:inbox\n\n" + "\tnotmuch search to:\"%s\"\n\n" + "\tnotmuch search from:\"%s\"\n\n" + "\tnotmuch search subject:\"my favorite things\"\n\n" + "See \"notmuch help search\" for more details.\n\n" + "You can also use \"notmuch show\" with any of the thread IDs resulting\n" + "from a search. Finally, you may want to explore using a more sophisticated\n" + "interface to notmuch such as the emacs interface implemented in notmuch.el\n" + "or any other interface described at http://notmuchmail.org\n\n" + "And don't forget to run \"notmuch new\" whenever new mail arrives.\n\n" + "Have fun, and may your inbox never have much mail.\n\n", + notmuch_config_get_user_name (config), + notmuch_config_get_user_primary_email (config)); -"The next step is to run \"notmuch new\" which will create a database\n" -"that indexes all of your mail. Depending on the amount of mail you have\n" -"the initial indexing process can take a long time, so expect that.\n" -"Also, the resulting database will require roughly the same amount of\n" -"storage space as your current collection of email. So please ensure you\n" -"have sufficient storage space available now.\n\n"); + notmuch_config_close (config); - return ret; + return 0; } int