1 /****************************************************************************
2 * Familia Lignum - Genealogical program *
3 * Copyright (C) 2011-2012 Rafał Długołęcki <rafal@dlugolecki.net.pl> *
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; version 2 of the License. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License along *
15 * with this program; if not, write to the Free Software Foundation, Inc., *
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
18 ****************************************************************************/
23 #include "../config.h"
27 #include "commandline.h"
30 static gboolean commandline_copyright;
32 static gchar **commandline_files = NULL;
34 static GOptionEntry program_options[] = {
35 { "copyright", 'c', 0, G_OPTION_ARG_NONE,
36 &commandline_copyright, "Show copyright", NULL},
38 { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY,
39 &commandline_files, "Files", "[file1] [file2]..." },
44 * @return True if program should continue. False otherwise.
46 gboolean commandline_parse(int *argc, char ***argv)
49 GOptionContext *context = NULL;
51 context = g_option_context_new("- genealogical program");
52 g_option_context_set_summary(context,
53 "Report bugs to " PACKAGE_BUGREPORT ".\n" \
54 PACKAGE_NAME " home page: <" PACKAGE_URL ">\n" \
55 "If you like this program, please send me a postcard. :)");
57 g_option_context_add_main_entries(context, program_options, NULL);
58 g_option_context_add_group(context, gtk_get_option_group(TRUE));
60 if(!g_option_context_parse(context, argc, argv, &error)) {
61 g_printerr("%s\n", error->message);
63 g_option_context_free(context);
67 if(commandline_copyright) {
68 g_print("%s\n", PACKAGE_STRING);
69 g_print("%s\n\n", COPYRIGHT);
70 g_print("%s\n", "License GPLv2: GNU GPL version 2 "
71 "<http://www.gnu.org/licenses/gpl-2.0.html>");
72 g_print("%s\n\n", LICENSE_SHORT);
76 if(commandline_files != NULL) {
77 GSList * slist = NULL;
79 for(i = 0; commandline_files[i] != NULL; i++) {
80 g_print("Parsing %s\n", commandline_files[i]);
81 slist = g_slist_prepend(slist,
82 g_strdup(commandline_files[i]));
84 commandline_files = g_slist_reverse(slist);
87 g_strfreev(commandline_files);
88 g_option_context_free(context);