summaryrefslogtreecommitdiff
path: root/libmailutils/cli/cli.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmailutils/cli/cli.c')
-rw-r--r--libmailutils/cli/cli.c69
1 files changed, 34 insertions, 35 deletions
diff --git a/libmailutils/cli/cli.c b/libmailutils/cli/cli.c
index 5b0a1896a..337002ad4 100644
--- a/libmailutils/cli/cli.c
+++ b/libmailutils/cli/cli.c
@@ -1,5 +1,5 @@
/* cli.c -- Command line interface for GNU Mailutils
- Copyright (C) 2016-2019 Free Software Foundation, Inc.
+ Copyright (C) 2016-2024 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -35,8 +35,6 @@
#include <mailutils/mu_auth.h>
#include <mailutils/gitinfo.h>
-#define MU_LEGACY_CONFIG_FILE SYSCONFDIR "/mailutils.rc"
-
#ifndef MU_SITE_CONFIG_FILE
# define MU_SITE_CONFIG_FILE SYSCONFDIR "/mailutils.conf"
#endif
@@ -55,10 +53,11 @@ const char mu_version_copyright[] =
/* Do *not* mark this string for translation. %s is a copyright
symbol suitable for this locale, and %d is the copyright
year. */
- "Copyright %s 2007-2019 Free Software Foundation, inc.";
+ "Copyright %s 2007-%d Free Software Foundation, inc.";
+int mu_copyright_year = 2024;
void
-mu_version_hook (struct mu_parseopt *po, mu_stream_t stream)
+mu_version_print (mu_stream_t stream)
{
#if MU_GIT_COMMIT_DISTANCE > 0
mu_stream_printf (stream, "%s (%s) %s-%d [%s]\n",
@@ -72,7 +71,7 @@ mu_version_hook (struct mu_parseopt *po, mu_stream_t stream)
/* TRANSLATORS: Translate "(C)" to the copyright symbol
(C-in-a-circle), if this symbol is available in the user's
locale. Otherwise, do not translate "(C)"; leave it as-is. */
- mu_stream_printf (stream, mu_version_copyright, _("(C)"));
+ mu_stream_printf (stream, mu_version_copyright, _("(C)"), mu_copyright_year);
mu_stream_printf (stream, _("\
\n\
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\n\
@@ -81,6 +80,12 @@ There is NO WARRANTY, to the extent permitted by law.\n\
"));
}
+void
+mu_version_hook (struct mu_parseopt *po, mu_stream_t stream)
+{
+ mu_version_print (stream);
+}
+
const char mu_general_help_text[] =
N_("General help using GNU software: <http://www.gnu.org/gethelp/>");
@@ -209,7 +214,7 @@ struct mu_option mu_common_options[] = {
MU_OPTION_END
};
-/* This varibales are used to construct the set of configuration
+/* These variables are used to construct the set of configuration
handling options.
*/
@@ -488,7 +493,8 @@ run_commit (void *item, void *data)
| MU_PARSEOPT_EXTRA_INFO \
| MU_PARSEOPT_VERSION_HOOK \
| MU_PARSEOPT_PROG_NAME \
- | MU_PARSEOPT_NEGATION)
+ | MU_PARSEOPT_NEGATION \
+ | MU_PARSEOPT_SPECIAL_ARGS )
void
mu_cli_ext (int argc, char **argv,
@@ -591,7 +597,12 @@ mu_cli_ext (int argc, char **argv,
po.po_help_hook = extra_help_hook;
flags |= MU_PARSEOPT_HELP_HOOK;
}
-
+ else if (pohint->po_flags & MU_PARSEOPT_HELP_HOOK)
+ {
+ po.po_help_hook = pohint->po_help_hook;
+ flags |= MU_PARSEOPT_HELP_HOOK;
+ }
+
if (setup->prog_doc_hook)
{
po.po_prog_doc_hook = prog_doc_hook;
@@ -622,7 +633,20 @@ mu_cli_ext (int argc, char **argv,
po.po_negation = pohint->po_negation;
if (flags & MU_PARSEOPT_PROG_NAME)
po.po_prog_name = pohint->po_prog_name;
-
+ if (flags & MU_PARSEOPT_SPECIAL_ARGS)
+ po.po_special_args = pohint->po_special_args;
+
+ if (setup->ex_usage)
+ {
+ po.po_exit_error = setup->ex_usage;
+ flags |= MU_PARSEOPT_EXIT_ERROR;
+ }
+ else if (pohint->po_flags & MU_PARSEOPT_EXIT_ERROR)
+ {
+ po.po_exit_error = pohint->po_exit_error;
+ flags |= MU_PARSEOPT_EXIT_ERROR;
+ }
+
appd.setup = setup;
appd.hints = &hints;
appd.append_tree = NULL;
@@ -630,8 +654,6 @@ mu_cli_ext (int argc, char **argv,
po.po_data = &appd;
flags |= MU_PARSEOPT_DATA;
- po.po_exit_error = setup->ex_usage;
-
mu_opool_create (&pool, MU_OPOOL_ENOMEMABRT);
optv = init_options (pool, capa, setup, &hints, &com_list);
@@ -649,29 +671,6 @@ mu_cli_ext (int argc, char **argv,
else if (argc)
mu_parseopt_error (&po, "%s", _("unexpected arguments"));
-#if defined(MU_LEGACY_CONFIG_FILE)
- if ((hints.flags & MU_CFHINT_SITE_FILE)
- && strcmp (hints.site_file, MU_SITE_CONFIG_FILE) == 0)
- {
- if (access (MU_LEGACY_CONFIG_FILE, F_OK) == 0)
- {
- if (access (hints.site_file, F_OK) == 0)
- {
- mu_diag_output (MU_DIAG_WARNING,
- _("legacy configuration file %s ignored"),
- MU_LEGACY_CONFIG_FILE);
- }
- else
- {
- mu_diag_output (MU_DIAG_WARNING,
- _("using legacy configuration file %s: please rename it to %s"),
- MU_LEGACY_CONFIG_FILE, MU_SITE_CONFIG_FILE);
- hints.site_file = MU_LEGACY_CONFIG_FILE;
- }
- }
- }
-#endif
-
if (mu_cfg_parse_config (&parse_tree, &hints))
exit (setup->ex_config);

Return to:

Send suggestions and report system problems to the System administrator.