[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Antiright-devel] antiright/gtkshell options.c
From: |
Jeffrey Bedard |
Subject: |
[Antiright-devel] antiright/gtkshell options.c |
Date: |
Wed, 21 Jul 2010 21:47:01 +0000 |
CVSROOT: /sources/antiright
Module name: antiright
Changes by: Jeffrey Bedard <jefbed> 10/07/21 21:47:01
Modified files:
gtkshell : options.c
Log message:
Added facility to compile list of valid command line arguments.
Use this list for usage information display.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/options.c?cvsroot=antiright&r1=1.43&r2=1.44
Patches:
Index: options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/options.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- options.c 2 Nov 2008 20:10:55 -0000 1.43
+++ options.c 21 Jul 2010 21:47:01 -0000 1.44
@@ -24,6 +24,7 @@
extern FILE *yyin, *yyout;
extern struct GDLEnvironment * gsh_guidl_env;
+static gchar * gsh_options_usage_string=NULL;
#ifdef DEBUG
static void
@@ -80,10 +81,18 @@
common_guidl_handler(gsh);
}
+static void print_usage(void)
+{
+ if(gsh_options_usage_string != NULL)
+ fprintf(stderr, "%s\n", gsh_options_usage_string);
+}
+
void
gsh_invalid_option(const gchar ** argv, const gint option)
{
g_warning("%s: %s undefined\n", argv[0], argv[option]);
+ print_usage();
+ exit(1);
}
#define HANDLE(type)\
@@ -103,13 +112,19 @@
guidl_handler_for_file(gsh, argv[++(*counter)]);
}
+
ARTupleVector *
gsh_define_command_line_options(void)
{
ARTupleVector * dictionary;
+ if(gsh_options_usage_string==NULL)
+ asprintf(&gsh_options_usage_string, "Usage: ");
+
#define ARTDEF(key, cb)\
- $(dictionary, add, key, (const gchar *)cb);
+ $(dictionary, add, key, (const gchar *)cb);\
+ asprintf(&gsh_options_usage_string, "%s [%s]",\
+ gsh_options_usage_string, key);
dictionary=ARNEW(ar, ARTupleVector);
- [Antiright-devel] antiright/gtkshell options.c,
Jeffrey Bedard <=