skip to main | skip to sidebar
Showing posts with label gengetopt. Show all posts
Showing posts with label gengetopt. Show all posts

Thursday, July 24, 2008

Gengetopt Eclipse 1.1.0

Here's the new version of the eclipse plugin for editing gengetopt files: http://ggoeclipse.sourceforge.net.

I've fixed a bug that did not make gengetopt editor share the standard text editor features such as line and column numbers and quick diffs.

Code completion is now improved and double quoted strings are automatically completed.

Furthermore I've implemented the formatting strategy so that the gengetopt file contents can be automatically formatted (probably this feature needs some more tweaking :-)


Furthermore, now a small help is available (basically it's the same content of the web page).

The next step should be the (background) parsing of the contents of the ggo file.

Pubblicato da betto a 3:35 PM 0 commenti

Etichette: , ,

Tuesday, January 29, 2008

Gengetopt Eclipse

I finally made it to create my very first eclipse plugin! :-)

Since I'm using eclipse for most of the time I wanted to get my hands dirty also with eclipse programming!

The eclipse plugin architecture and framework is very powerful, but I can't say it's quite easy to understand... at least at the very beginning. But probably this is only the main drawback of every framework (e.g., all the GUI frameworks...) and with the right documentation, the learning curve gets better every day.

Besides the documentation you find on-line, I've been using the book Eclipse: Building Commercial Quality Plug-ins, Second Edition, by Eric Clayberg and Dan Rubel (Addison-Wesley, Second Edition, 2006), which really does a very good job in explaining the eclipse plugin architecture in many details and providing a lot of code (without which, it would be otherwise quite hard to get acquainted with eclipse programming).

The plugin I decided to develop was an editor for GNU Gengetopt files, so that I could easily write those files in all my GNU projects (which are in C++, and I'm using eclipse also for them).

As for eclipse editor programming, the book above did not help a lot... fortunately, I found some more information in the book Eclipse in Action, which is a little bit out of date, but it still contains valueable information.

Here's some more info:

You can find Gengetopt Eclipse here: http://ggoeclipse.sourceforge.net

Gengetopt Eclipse is an Eclipse plugin providing an editor for GNU Gengetopt input files.

For the moment, this editor provides syntax highlighting and code completion (new features will be added in the future).

There is currently no associated builder, since it is assumed that gengetopt files are used in projects using makefiles.

Gengetopt eclipse is free and open source, under the GNU GPL License.

Installation

As with most eclipse plugins, the easiest way to install gengetopt eclipse is via the eclipse update manager:
  1. Help -> Software Updates -> Find and Install
  2. Search for new features to install
  3. New Remote Site
  4. Name: Gengetopt Eclipse, URL: http://ggoeclipse.sf.net/update
Alternatively, you can download the zip file containing the plugin and unzip it inside the eclipse directory. The zip can be downloaded from here: http://sourceforge.net/projects/ggoeclipse.

Sources

The sources of gengetopt eclipse can be obtained via CVS (you can find the instructions here: http://sourceforge.net/projects/ggoeclipse)

Screenshot


Pubblicato da betto a 11:01 PM 4 commenti

Etichette: , ,

Tuesday, January 15, 2008

GNU Gengetopt 2.22

The new release of GNU Gengetopt is available.

Apart from the classical bugfixes, the main change in this release is the generated code which should be now shorter (in most cases) and, most of all, cleaner and easier to understand (hopefully). Surely it should be easier now to add some new features. In particular the handling of an option (and its possible argument) is completely delegate to a single function (update_arg) which can handle all the combinations of kinds of options (required or optional options, options with optional arguments, all the types, etc.); also the corresponding function for dealing with multiple options internally relies on this function.

During the refactoring of the generated code, I took the chance to add some requested features (and this somehow proved that the new generated code is easier to deal with):

  • the automatic error printing done by the getopt_long function can now be suppressed by passing an additional parameter to the generated function (so that the programmer can customize the error reporting or also consider what getopt_long thinks is an error not an error)
  • options with values can now be given a specific type (the same types available for other options), and, in particular, the type enum is available for this kind of options, and this will correspond to a C enum in the generated file
  • when there are more than one kind of help output (e.g., in the presence of hidden options) the generated help strings avoid duplicating string constant, so that the memory footprint should be minor
  • options can be given an additional field, details, where one can specify a more verbose option description; this will add to the generated parser the command line option --detailed-help; in this case also the details will be printed. This way, the user can have the standard help output and a more detailed one.
  • the programmer can completely handle manually --help and --version, even redefine them. In particular, if the gengetopt options --no-help and --no-version are specified, gengetopt will not generate the automatic --help and --version options in the generated parser.
Finally, another requested feature was added: mutually exclusive groups of options (that are different from group options that were already present and that represent groups of mutually exclusive options). This new feature is called mode options (since they can represent the different modes a program can execute). Thus, when you specify an option belonging to a mode, you're not allowed to specify an option belonging to a different mode. Of course, you can still have options that do not belonging to any mode.

Pubblicato da betto a 8:33 AM 4 commenti

Etichette:

Saturday, August 04, 2007

GNU Gengetopt 2.21

It wasn't long ago since I released version 2.20 of GNU Gengetopt, and here's a new version.

First of all, I switched to version 3 of GPL.

Another novelty is that gengetopt generates doxygen comments in the generated header files. This way, if you use doxygen on your sources, you'll find also the documentation of the code generated by gengetopt.

Some build issues were fixed: parallel makes work again, and the make files do not depend on GNU make specific features (such as %. rules which are not standard - I must admit I didn't know this, but the new version of automake I started to use, i.e., version 1.10, reports a warning when you use such rules in your Makefile.am files, so I got to know about the problem).

Furthermore, the signatures of generated parser functions changed in a crucial way (of course, the previous signatures are still available, but they are deprecated and possibly removed in the future). In particular, besides the default parser functions (i.e., with default options), other versions are generated that accept further options, such as, e.g., initialize the argument structure, perform required options checks, etc. In the previous versions, this additional signature, whose name was the same as the main parser function with a 2 in the end, used to accept these options as single boolean (actually, integers) parameters. There's nothing wrong with this approach but it does not scale to future enhancements of the signature. In fact, a user requested another option (see the list of changes below) and adding that parameter to the signature would break existing code when regenerating the parser functions, since the code using those functions must be manually modified in order to use the new signature (in C++ this might be a small problem thanks to default values for parameters, but in C...). For this reason, the options are passed to the parser function in the shape of a structure: adding a field in the structure will not break existing code since the signature of the parser functions does not change. Notice that the structure object for these options should not be manually created and initialized (again, if a new field is added in future versions, that field might stay uninitialized), but it should be created and initialized by calling the dedicated generated init function. Here's a snippet of the generated header file (notice the new structure, the new signature with the _ext at the end, the deprecated old signature, and the init function for options):

/** @brief The additional parameters to pass to parser functions */
struct cmdline_parser_params
{
int override; /**< @brief whether to override possibly already present options (default 0) */
int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 0) */
int check_required; /**< @brief whether to check that all required options were provided (default 0) */
int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
} ;

/**
* The command line parser
* @param argc the number of command line options
* @param argv the command line options
* @param args_info the structure where option information will be stored
* @return 0 if everything went fine, NON 0 if an error took place
*/
int cmdline_parser (int argc, char * const *argv,
struct gengetopt_args_info *args_info);

/**
* The command line parser (version with additional parameters - deprecated)
* @param argc the number of command line options
* @param argv the command line options
* @param args_info the structure where option information will be stored
* @param override whether to override possibly already present options
* @param initialize whether to initialize the option structure my_args_info
* @param check_required whether to check that all required options were provided
* @return 0 if everything went fine, NON 0 if an error took place
* @deprecated use cmdline_parser_ext() instead
*/
int cmdline_parser2 (int argc, char * const *argv,
struct gengetopt_args_info *args_info,
int override, int initialize, int check_required);

/**
* The command line parser (version with additional parameters)
* @param argc the number of command line options
* @param argv the command line options
* @param args_info the structure where option information will be stored
* @param params additional parameters for the parser
* @return 0 if everything went fine, NON 0 if an error took place
*/
int cmdline_parser_ext (int argc, char * const *argv,
struct gengetopt_args_info *args_info,
struct cmdline_parser_params *params);

/**
* Allocates dynamically a cmdline_parser_params structure and initializes
* all its fields to 0
* @return the initialized cmdline_parser_params structure
*/
struct cmdline_parser_params *cmdline_parser_params_init();

Finally, here's the complete list of the new features:

* a structure for parser function parameters (that might be extended
in future versions)
* a parser parameter to check whether an option that is parsed is
already present in the args_info struct (suggested by
Yegor Yefremov)
* the generated files contain doxygen documentation (suggested by
Yegor Yefremov)
* parallel make works
* generated make files should not depend on GNU make
* fixed a bug with multiple options with back slashes (thanks to
Peter Kovacs)
* updated to version 3 of GPL

Pubblicato da betto a 10:51 AM 0 commenti

Etichette:

Thursday, July 05, 2007

Gengetopt 2.20

I released version 2.20 of GNU Gengetopt.

As usual, this new release fixes some bugs:

If --include-getopt is specified then the generated parser is actually independent of getopt.h; this way, the included getopt functions code, which will actually be used, will not conflict with possible signatures found in getopt.h; moreover, if getopt.h is not present in the system at all, you won't get an error (bug fixed thanks to Tiago Menezes).

In the --help output a section name and description will not be generated if all its options are hidden (thanks to Edsko de Vries).

I've added the command line option --default-optional that permits specifying that all options are by default optional (unless explicitely specified). In fact, up to now, all options were considered mandatory if not specified otherwise; this might not be a comfortable behavior, but I couldn't change it without breaking existing code... but if you use this command line option for gengetopt, you'll avoid this possible unwanted behavior.

A bug was fixed in the included getopt functions code when --include-getopt is specified.

Finally, I fixed a bug when using args entry in the .ggo file (thanks to Christian Gagneraud). In fact, if in the args entry you specify options such as --file-name the memory was corrupted with possible unexpected behavior. Moreover, now all the options specified in the args entry are taken into consideration.

Pubblicato da betto a 4:43 PM 1 commenti

Etichette:

Thursday, January 18, 2007

GNU Gengetopt 2.19.1

Although I released 2.19 of GNU Gengetopt few weeks ago, I had to release a fixed version: 2.19.1, http://www.gnu.org/software/gengetopt.

This release basically fixes some bugs such as:

  • fixed compilation problem that can make 'make check' fail on some systems
    lacking getopt_long.
  • fixed a test problem when not using GNU sed
  • in strings # comments are not considered
The first problem was quite interesting, since it was due to not passing to the C compiler the right command line switches, in particular the switch specifying the paths where to look for header files. In systems where getopt_long is not provided (or it is provided in a not too up to date version), the configure script provides the right version of sources with getopt_long functions. However, you must make sure to include the right version of the header file containing the prototype for getopt_long, otherwise, the C compiler will use the header file of the C library (this, of course, happens only in the case where the C library provides this function, but configure detected that it does not behave correctly - this is accomplished by using GNU Gnulib) and links to the customized version of getopt_long. Of course, the results will be unpredictable!

The second problem was due to a usage of sed with a regular expression which seems to work with GNU sed, but not with BSD sed (actually I don't know which version misbehaves). The solution was provided by Bob White (thanks again Bob!) and it is also online here.

The problem was that I was using this sed command line:
sed -e "s/^\(\([^\/]*\)\/\)\+//g"
in order to remove the directories of a path, while it was sufficient to use this simpler command line:
sed -e "s/^.*\///g"
since the * is greedy and will match the last /. Well done Bob! :-)

Pubblicato da betto a 10:33 AM 0 commenti

Etichette:

Tuesday, January 02, 2007

GNU Gengetopt 2.19

Happy New Year :-)

I've just released the new version of GNU Gengetopt 2.19: http://www.gnu.org/software/gengetopt.

This release basically fixes some bugs such as:

  • Wherever they can be specified, strings can spawn more than one line and contain escaped " (e.g., \");
  • with --long-help the optional options are correctly printed between [];
  • Now --no-handle-help correctly handles also --full-help (thanks to Gyozo Papp), i.e., when --no-handle-help is specified in gengetopt, the generated command line parser will not handle automatically the --full-help, but will allow the programmer to do so;
  • automatically generated usage strings are now correctly wrapped.
Besides these bug fix, some enhancements were added (basically based on users requests):
  • usage string can be specified by the programmer in the .ggo file, thus overriding the one generated automatically by gengetopt;
  • the programmer can also specify in the .ggo file a description string that will be printed after the usage string, in the --help output;
  • configuration files can include other configuration files (thanks to David Bird), using the include keyword
  • the option --show-required was added: if specified to gengetopt, the generated help output will print the string "(mandatory)" after the description of each required option; you can also specify the string that has to be printed, instead of the default "(mandatory)"
These new features should make the code produced by gengetopt (in particular, with these features, the generated output of --help) more customizable. Since now you can use purpose, usage and description as you see fit.

Pubblicato da betto a 5:04 PM 0 commenti

Etichette:

Friday, September 29, 2006

GNU Gengetopt 2.18

I released few days ago the new version of GNU Gengetopt, http://www.gnu.org/software/gengetopt, a GNU program I'm the maintainer of.

Gengetopt is a generator of parsers of command line options.

It generates a C function that uses getopt_long function to parse the command line options, to validate them and fills a struct. Thus your program can handle options such as:

myprog --input foo.c -o foo.o --no-tabs -i 100 *.class
And both long options (those that start with --) and short options (start with - and consist of only one character) can be handled. For standards about short and long options you may want to take a look at the GNU Coding Standards.

Command line options are an important feature of every non trivial programs. The getopt functions already do a good job in parsing them, but a lot of programming is still require... Gengetopt will do this additional programming for you, and you simply have to provide a file with the specification of the options your program accepts.

I refer the interested programmers to gengetopt's documentation.

Pubblicato da betto a 3:48 PM 7 commenti

Etichette: ,

Subscribe to: Posts (Atom)
 

AltStyle によって変換されたページ (->オリジナル) /