]> granicus.if.org Git - neomutt/commitdiff
Added -B option for batch mode. exiting before any mail sending feature
authorGuyzmo <guyzmo+github+pub@m0g.net>
Mon, 16 Jan 2017 21:29:34 +0000 (22:29 +0100)
committerRichard Russon <rich@flatcap.org>
Sat, 11 Mar 2017 19:10:59 +0000 (19:10 +0000)
main.c

diff --git a/main.c b/main.c
index fd911907b0e6bed2026525afdae898fb78c46235..735283b16097349d6703a48e6b95aecdbd58afc3 100644 (file)
--- a/main.c
+++ b/main.c
@@ -89,6 +89,7 @@ static void mutt_usage (void)
        mutt [<options>] -p\n\
        mutt [<options>] -A <alias> [...]\n\
        mutt [<options>] -Q <query> [...]\n\
+       mutt [<options>] -B\n\
        mutt [<options>] -D [-S]\n\
        mutt -v[v]\n"));
 
@@ -100,7 +101,8 @@ options:\n\
   -b <address>\tspecify a blind carbon-copy (BCC) address\n\
   -c <address>\tspecify a carbon-copy (CC) address\n\
   -D\t\tprint the value of all variables to stdout\n\
-  -D -S\t\tlike -D, but hide the value of sensitive variables"));
+  -D -S\t\tlike -D, but hide the value of sensitive variables\n\
+  -B\t\trun in batch mode (do not start the ncurses UI)"));
 #if DEBUG
   puts (_("  -d <level>\tlog debugging output to ~/.muttdebug0"));
 #endif
@@ -199,6 +201,7 @@ int main (int argc, char **argv, char **environ)
   int explicit_folder = 0;
   int dump_variables = 0;
   int hide_sensitive = 0;
+  int batch_mode = 0;
   int edit_infile = 0;
   extern char *optarg;
   extern int optind;
@@ -264,9 +267,9 @@ int main (int argc, char **argv, char **environ)
     }
 
 #ifdef USE_NNTP
-    if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:Ee:g:GH:s:i:hm:npQ:RSvxyzZ")) != EOF)
+    if ((i = getopt (argc, argv, "+A:a:Bb:F:f:c:Dd:Ee:g:GH:s:i:hm:npQ:RSvxyzZ")) != EOF)
 #else
-    if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:Ee:H:s:i:hm:npQ:RSvxyzZ")) != EOF)
+    if ((i = getopt (argc, argv, "+A:a:Bb:F:f:c:Dd:Ee:H:s:i:hm:npQ:RSvxyzZ")) != EOF)
 #endif
       switch (i)
       {
@@ -303,6 +306,10 @@ int main (int argc, char **argv, char **environ)
        dump_variables = 1;
        break;
 
+      case 'B':
+        batch_mode = 1;
+        break;
+
       case 'd':
 #ifdef DEBUG
        if (mutt_atoi (optarg, &debuglevel) < 0 || debuglevel <= 0)
@@ -419,7 +426,7 @@ int main (int argc, char **argv, char **environ)
   }
 
   /* Check for a batch send. */
-  if (!isatty (0) || queries || alias_queries || dump_variables)
+  if (!isatty (0) || queries || alias_queries || dump_variables || batch_mode)
   {
     set_option (OPTNOCURSES);
     sendflags = SENDBATCH;
@@ -513,6 +520,9 @@ int main (int argc, char **argv, char **environ)
     }
   }
 
+  if (batch_mode)
+      exit(0);
+
   if (sendflags & SENDPOSTPONED)
   {
     if (!option (OPTNOCURSES))