2 * gEDA/gaf command-line utility
3 * Copyright (C) 2012-2013 Peter Brett <peter@peter-b.co.uk>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 /* Gettext translation */
39 #define short_options "+hV"
41 static struct option long_options
[] =
43 {"help", 0, NULL
, 'h'},
44 {"version", 0, NULL
, 'V'},
45 {"no-rcfiles", 0, NULL
, 2},
49 struct internal_command
{
51 int (*func
)(int, char **);
54 static struct internal_command commands
[] =
57 {"config", cmd_config
},
58 {"export", cmd_export
},
62 /* Print help info and exit */
66 printf (_("Usage: gaf [OPTION...] COMMAND [ARGS ...]\n"
68 "gEDA/gaf command-line utility.\n"
71 " --no-rcfiles inhibit loading of 'gafrc' files\n"
72 " -h, --help display usage information and exit\n"
73 " -V, --version display version information and exit\n"
75 "Commonly-used commands (type `gaf <cmd> --help' for usage):\n"
76 " shell Scheme REPL for interactive gEDA data processing\n"
77 " config Edit gEDA configuration\n"
78 " export Export gEDA files in various image formats.\n"
80 "Please report bugs to %s.\n"),
85 /* Print version info and exit */
89 printf(_("gEDA/gaf %s (g%.7s)\n"
90 "Copyright (C) 1998-2020 gEDA developers\n"
91 "This is free software, and you are welcome to redistribute it under\n"
92 "certain conditions. For details, see the file `COPYING', which is\n"
93 "included in the gEDA distribution.\n"
94 "There is NO WARRANTY, to the extent permitted by law.\n"),
95 PACKAGE_DOTTED_VERSION
, PACKAGE_GIT_COMMIT
);
100 main (int argc
, char **argv
)
105 char **cmd_argv
= NULL
;
106 int (*cmd_func
)(int, char **) = NULL
;
110 setlocale (LC_ALL
, "");
111 bindtextdomain ("geda-gaf", LOCALEDIR
);
112 textdomain ("geda-gaf");
113 bind_textdomain_codeset ("geda-gaf", "UTF-8");
116 while (-1 != (c
= getopt_long (argc
, argv
, short_options
,
117 long_options
, NULL
))) {
121 /* This is a long-form-only flag option, and has already been
122 * dealt with by getopt_long(). */
125 case 2: /* --no-rcfiles */
126 g_setenv ("GAF_INHIBIT_RCFILES", "1", 1);
136 /* getopt_long already printed an error message */
137 fprintf (stderr
, _("\nRun `gaf --help' for more information.\n"));
142 g_assert_not_reached ();
146 /* The next argument should be a command */
147 if (optind
== argc
) {
149 _("ERROR: You must specify a command to run.\n"
151 "Run `gaf --help' for more information.\n"));
157 /* Look up the command */
159 for (i
= 0; commands
[i
].name
!= NULL
; i
++) {
160 if (strcmp (cmd
, commands
[i
].name
) == 0) {
161 cmd_func
= commands
[i
].func
;
165 if (cmd_func
== NULL
) {
167 _("ERROR: Unrecognised command `%s'.\n"
169 "Run `gaf --help' for more information.\n"),
174 cmd_argc
= argc
- optind
;
175 cmd_argv
= argv
+ optind
;
178 return cmd_func (cmd_argc
, cmd_argv
);