--version: Add QUVI_VERSION_SCRIPTS_CONFIGURATION to output
[quvi-tool.git] / src / opts / err.c
blobcf288194e5c9ffbd4de7bf06a2092712ab224fc6
1 /* quvi
2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This file is part of quvi <http://quvi.sourceforge.net/>.
6 * This program is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Affero General Public
8 * License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General
17 * Public License along with this program. If not, see
18 * <http://www.gnu.org/licenses/>.
21 #include "config.h"
23 #include <stdlib.h>
24 #include <glib/gi18n.h>
26 #include "lopts.h"
28 enum {IGNORE_VARIABLE, INVALID_VALUE, POSSIBLE_VALUES};
30 static const gchar *_E[] =
32 N_("error: %s:\n ignoring the variable `%s' with an invalid value `%s'\n"),
33 N_("error: invalid value `%s' for the option `--%s'\n"),
34 N_("Possible values for the option:\n"),
35 NULL
38 gint lopts_invalid_value(const gchar *opt_name,
39 const gchar *config_fpath,
40 const gchar *inv_value,
41 const gchar **possible_values)
43 if (config_fpath != NULL)
45 g_printerr(g_dgettext(GETTEXT_PACKAGE, _E[IGNORE_VARIABLE]),
46 config_fpath, opt_name, inv_value);
48 else
50 g_printerr(g_dgettext(GETTEXT_PACKAGE, _E[INVALID_VALUE]),
51 inv_value, opt_name);
54 if (possible_values != NULL)
56 gint i = 0;
57 g_printerr("%s", g_dgettext(GETTEXT_PACKAGE, _E[POSSIBLE_VALUES]));
59 while (possible_values[i] != NULL)
60 g_printerr(" %s\n", possible_values[i++]);
62 return (EXIT_FAILURE);
65 /* vim: set ts=2 sw=2 tw=72 expandtab: */