commit-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Mailutils branch, master, updated. release-2.2-795-g4872fc4


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-795-g4872fc4
Date: Mon, 24 Oct 2016 06:09:52 +0000 (UTC)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=4872fc4fb478af6c718fad0a43004fdbebc53fc0

The branch, master has been updated
       via  4872fc4fb478af6c718fad0a43004fdbebc53fc0 (commit)
      from  cd577bf9f6ce6fa3402b34f322516e49a9e72d00 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4872fc4fb478af6c718fad0a43004fdbebc53fc0
Author: Sergey Poznyakoff <address@hidden>
Date:   Mon Oct 24 09:04:09 2016 +0300

    Improve program usage output.
    
    * include/mailutils/opt.h (MU_PARSEOPT_SPECIAL_ARGS): New flag.
    (mu_parseopt)<po_special_args>: New field.
    * libmailutils/opt/help.c (option_summary)
    (print_program_usage): Print po_special_args, if defined.
    * libmailutils/opt/opt.c (parseopt_init): Initialize po_special_args
    unless MU_PARSEOPT_SPECIAL_ARGS is set.
    
    MH: Advertise [+FOLDER] special argument if the -folder option is declared.
    
    * mh/mh_getopt.c (folder_option): Bugfix: -folder takes argument.
    (mh_getopt): Set po_special_args if the -folder option is declared.
    * mh/inc.c: Fix arg_doc.
    * mh/mhpath.c: Likewise.
    * mh/repl.c: Likewise.
    * mh/rmf.c: Likewise.
    * mh/rmm.c: Likewise.
    * mh/scan.c: Likewise.
    * mh/show.c: Likewise.

-----------------------------------------------------------------------

Summary of changes:
 include/mailutils/opt.h |    5 ++++-
 libmailutils/opt/help.c |   14 +++++++++-----
 libmailutils/opt/opt.c  |    2 ++
 mh/inc.c                |    3 +--
 mh/mh_getopt.c          |   28 ++++++++++++++++++++++++++--
 mh/mhpath.c             |    2 +-
 mh/repl.c               |    2 +-
 mh/rmf.c                |    3 +--
 mh/rmm.c                |    2 +-
 mh/scan.c               |    2 +-
 mh/show.c               |    2 +-
 11 files changed, 48 insertions(+), 17 deletions(-)

diff --git a/include/mailutils/opt.h b/include/mailutils/opt.h
index 6a7f2dc..268956d 100644
--- a/include/mailutils/opt.h
+++ b/include/mailutils/opt.h
@@ -109,6 +109,8 @@ struct mu_option_cache
 #define MU_PARSEOPT_SINGLE_DASH    0x02000000
 /* Negation prefix is set */
 #define MU_PARSEOPT_NEGATION       0x04000000
+/* po_special_args is set */
+#define MU_PARSEOPT_SPECIAL_ARGS   0x08000000
 
 /* Reuse mu_parseopt struct initialized previously */
 #define MU_PARSEOPT_REUSE          0x80000000
@@ -131,8 +133,9 @@ struct mu_parseopt
   
   /* Informational: */
   char const *po_prog_name;
-  char const *po_prog_doc;     
+  char const *po_prog_doc;
   char const **po_prog_args;
+  char const *po_special_args;     /* Special option-like arguments */
   char const *po_bug_address;
   char const *po_package_name;
   char const *po_package_url;
diff --git a/libmailutils/opt/help.c b/libmailutils/opt/help.c
index 538e311..d24bbe7 100644
--- a/libmailutils/opt/help.c
+++ b/libmailutils/opt/help.c
@@ -523,6 +523,9 @@ option_summary (struct mu_parseopt *po, mu_stream_t str)
        }
     }
 
+  if (po->po_special_args)
+    mu_stream_printf (str, " %s", gettext (po->po_special_args));
+  
   free (idxbuf);
 }  
 
@@ -535,10 +538,7 @@ print_program_usage (struct mu_parseopt *po, int optsum, 
mu_stream_t str)
   
   usage_text = _("Usage:");
 
-  if (po->po_flags & MU_PARSEOPT_PROG_ARGS)
-    arg_text = po->po_prog_args;
-  else
-    arg_text = NULL;
+  arg_text = po->po_prog_args;
   i = 0;
   
   do
@@ -552,7 +552,11 @@ print_program_usage (struct mu_parseopt *po, int optsum, 
mu_stream_t str)
          optsum = 0;
        }
       else
-       mu_stream_printf (str, "[%s...]", _("OPTION"));
+       {
+         mu_stream_printf (str, "[%s...]", _("OPTION"));
+         if (po->po_special_args)
+           mu_stream_printf (str, " %s", gettext (po->po_special_args));
+       }
 
       if (arg_text)
        {
diff --git a/libmailutils/opt/opt.c b/libmailutils/opt/opt.c
index 3a34a7f..26633bb 100644
--- a/libmailutils/opt/opt.c
+++ b/libmailutils/opt/opt.c
@@ -578,6 +578,8 @@ parseopt_init (struct mu_parseopt *po, struct mu_option 
**options,
     po->po_prog_doc = NULL;
   if (!(flags & MU_PARSEOPT_PROG_ARGS))
     po->po_prog_args = NULL;
+  if (!(flags & MU_PARSEOPT_SPECIAL_ARGS))
+    po->po_special_args = NULL;
   if (!(flags & MU_PARSEOPT_BUG_ADDRESS))
     po->po_bug_address = NULL;
   if (!(flags & MU_PARSEOPT_PACKAGE_NAME))
diff --git a/mh/inc.c b/mh/inc.c
index ed9c011..1477dd5 100644
--- a/mh/inc.c
+++ b/mh/inc.c
@@ -26,7 +26,6 @@ static char extra_doc[] = N_("Debug flags are:\n\
   t - sieve trace (MU_SIEVE_DEBUG_TRACE)\n\
   i - sieve instructions trace (MU_SIEVE_DEBUG_INSTR)\n\
   l - sieve action logs");
-static char args_doc[] = N_("[+FOLDER]");
 
 static char *format_str = mh_list_format;
 static int width = 80;
@@ -345,7 +344,7 @@ main (int argc, char **argv)
   size_t lastseen;
   const char *unseen_seq;
   
-  mh_getopt (&argc, &argv, options, 0, args_doc, prog_doc, extra_doc);
+  mh_getopt (&argc, &argv, options, 0, NULL, prog_doc, extra_doc);
   if (!append_folder)
     append_folder = mh_global_profile_get ("Inbox", "inbox");
   if (argc)
diff --git a/mh/mh_getopt.c b/mh/mh_getopt.c
index 13feda9..08c9001 100644
--- a/mh/mh_getopt.c
+++ b/mh/mh_getopt.c
@@ -135,7 +135,7 @@ mh_opt_set_folder (struct mu_parseopt *po, struct mu_option 
*opt,
 }
 
 static struct mu_option folder_option[] = {
-  { "folder", 0, NULL, MU_OPTION_DEFAULT,
+  { "folder", 0, N_("FOLDER"), MU_OPTION_DEFAULT,
     N_("set current folder"),
     mu_c_string, NULL, mh_opt_set_folder },
   MU_OPTION_END
@@ -164,6 +164,19 @@ There is NO WARRANTY, to the extent permitted by law.\n\
 "));
 }
 
+static int
+has_folder_option (struct mu_option *opt)
+{
+  while (!MU_OPTION_IS_END (opt))
+    {
+      if (MU_OPTION_IS_VALID_LONG_OPTION (opt)
+         && strcmp (opt->opt_long, "folder") == 0)
+       return 1;
+      ++opt;
+    }
+  return 0;
+}
+
 void
 mh_getopt (int *pargc, char ***pargv, struct mu_option *options,
           int mhflags,
@@ -184,6 +197,12 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option 
*options,
   po.po_negation = "no";
   flags |= MU_PARSEOPT_NEGATION;
 
+  if ((mhflags & MH_GETOPT_DEFAULT_FOLDER) || has_folder_option (options))
+    {
+      po.po_special_args = N_("[+FOLDER]");
+      flags |= MU_PARSEOPT_SPECIAL_ARGS;
+    }
+
   if (argdoc)
     {
       args[0] = argdoc;
@@ -248,7 +267,12 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option 
*options,
 
   if (!argdoc && argc)
     {
-      mu_error (_("Extra arguments"));
+      mu_diag_init ();
+      mu_stream_printf (mu_strerr, "\033s<%d>", MU_DIAG_ERROR);
+      mu_stream_printf (mu_strerr, "%s", _("unrecognized extra arguments:"));
+      for (i = 0; i < argc; i++)
+       mu_stream_printf (mu_strerr, " %s", argv[i]);
+      mu_stream_write (mu_strerr, "\n", 1, NULL);
       exit (1);
     }
 
diff --git a/mh/mhpath.c b/mh/mhpath.c
index c1fe01f..dd1ce94 100644
--- a/mh/mhpath.c
+++ b/mh/mhpath.c
@@ -20,7 +20,7 @@
 #include <mh.h>
 
 static char prog_doc[] = N_("Print full pathnames of GNU MH messages and 
folders");
-static char args_doc[] = N_("[+FOLDER] [MSGLIST]");
+static char args_doc[] = N_("[MSGLIST]");
 
 static int
 mhpath (size_t num, mu_message_t msg, void *data)
diff --git a/mh/repl.c b/mh/repl.c
index d546d2c..13fa8c9 100644
--- a/mh/repl.c
+++ b/mh/repl.c
@@ -23,7 +23,7 @@
 #include <unistd.h>
 
 static char prog_doc[] = N_("Reply to a message");
-static char args_doc[] = N_("[+FOLDER] [MESSAGE]");
+static char args_doc[] = N_("[MESSAGE]");
 
 static char *format_str = NULL;
 static mh_format_t format;
diff --git a/mh/rmf.c b/mh/rmf.c
index 17e9cf2..40748c3 100644
--- a/mh/rmf.c
+++ b/mh/rmf.c
@@ -29,7 +29,6 @@
 #include <dirent.h>
 
 static char prog_doc[] = N_("Remove a GNU MH folder");
-static char args_doc[] = N_("[+FOLDER]");
 
 int explicit_folder; /* Was the folder explicitly given */
 int interactive; /* Ask for confirmation before deleting */
@@ -150,7 +149,7 @@ main (int argc, char **argv)
   int status;
   char *name;
 
-  mh_getopt (&argc, &argv, options, 0, args_doc, prog_doc, NULL);
+  mh_getopt (&argc, &argv, options, 0, NULL, prog_doc, NULL);
 
   cur_folder_path = current_folder_path ();
 
diff --git a/mh/rmm.c b/mh/rmm.c
index c0ba7d5..50675eb 100644
--- a/mh/rmm.c
+++ b/mh/rmm.c
@@ -20,7 +20,7 @@
 #include <mh.h>
 
 static char prog_doc[] = N_("Remove messages");
-static char args_doc[] = N_("[+FOLDER] [MSGLIST]");
+static char args_doc[] = N_("[MSGLIST]");
 
 static int
 rmm (size_t num, mu_message_t msg, void *data)
diff --git a/mh/scan.c b/mh/scan.c
index 29ed31e..5defd8a 100644
--- a/mh/scan.c
+++ b/mh/scan.c
@@ -27,7 +27,7 @@
 #include <mailutils/observer.h>
 
 static char prog_doc[] = N_("Produce a one line per message scan listing");
-static char args_doc[] = N_("[+FOLDER] [MSGLIST]");
+static char args_doc[] = N_("[MSGLIST]");
 
 static int clear;
 static char *format_str = mh_list_format;
diff --git a/mh/show.c b/mh/show.c
index ca7330c..ecac725 100644
--- a/mh/show.c
+++ b/mh/show.c
@@ -20,7 +20,7 @@
 #include <mh.h>
 
 static char prog_doc[] = N_("Display GNU MH messages");
-static char args_doc[] = N_("[+FOLDER] [MSGLIST]");
+static char args_doc[] = N_("[MSGLIST]");
 
 int use_draft;
 int use_showproc = 1;


hooks/post-receive
-- 
GNU Mailutils



reply via email to

[Prev in Thread] Current Thread [Next in Thread]