AutoGen - The Automated Program Generator: 7.5.11 Library of Standard Options

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

### 7.5.11 Library of Standard Options

AutoOpts has developed a set of standardized options. You may incorporate these options in your program simply by first adding a `#define` for the options you want, and then the line,

    #include stdoptions.def

in your option definitions. The supported options are specified thus:

    #define DEBUG
    #define DIRECTORY
    #define DRY_RUN
    #define INPUT
    #define INTERACTIVE
    #define OUTPUT
    #define WARN

    #define SILENT
    #define QUIET
    #define BRIEF
    #define VERBOSE

By default, only the long form of the option will be available. To specify the short (flag) form, suffix these names with `_FLAG`. e.g.,

    #define DEBUG_FLAG

`--silent`, `--quiet`, `--brief` and `--verbose` are related in that they all indicate some level of diagnostic output. These options are all designed to conflict with each other. Instead of four different options, however, several levels can be incorporated by `#define`-ing `VERBOSE_ENUM`. In conjunction with `VERBOSE`, it incorporates the notion of 5 levels in an enumeration: `silent`, `quiet`, `brief`, `informative` and `verbose`; with the default being `brief`.

Here is an example program that uses the following set of definitions:

    AutoGen Definitions options;

    prog-name  = default-test;
    prog-title = 'Default Option Example';
    homerc     = '$$/../share/default-test', '$HOME', '.';
    environrc;
    long-opts;
    gnu-usage;
    usage-opt;
    version    = '1.0';
    main = {
      main-type = shell-process;
    };
    #define DEBUG_FLAG
    #define WARN_FLAG
    #define WARN_LEVEL
    #define VERBOSE_FLAG
    #define VERBOSE_ENUM
    #define DRY_RUN_FLAG
    #define OUTPUT_FLAG
    #define INPUT_FLAG
    #define DIRECTORY_FLAG
    #define INTERACTIVE_FLAG
    #include stdoptions.def

Running a few simple commands on that definition file:

    autogen default-test.def
    copts="-DTEST_DEFAULT_TEST_OPTS `autoopts-config cflags`"
    lopts="`autoopts-config ldflags`"
    cc -o default-test ${copts} default-test.c ${lopts}

Yields a program which, when run with ‘`--help`’, prints out:

    default-test - Default Option Example - Ver. 1.0
    USAGE:  default-test [ -<flag> [<val>] | --<name>[{=| }<val>] ]...

    The following options are commonly used and are provided and supported
    by AutoOpts:

       -D, --debug                run program with debugging info
       -V, --verbose=KWd          run program with progress info
       -w, --warn=num             specify a warning-level threshhold
                                    - disabled as --no-warn
       -R, --dry-run              program will make no changes
       -I, --interactive=str      prompt for confirmation
       -i, --input=str            redirect input from file
       -o, --output=str           redirect output to file
       -d, --directory=str        use specified dir for I/O

    version and help options:

       -v, --version[=arg]        Output version information and exit
       -?, --help                 Display extended usage information and exit
       -!, --more-help            Extended usage information passed thru pager
       -u, --usage                Abbreviated usage to stdout
       ->, --save-opts[=arg]      Save the option state to a config file
       -<, --load-opts=str        Load options from a config file
                                    - disabled as --no-load-opts
                                    - may appear multiple times

    Options are specified by doubled hyphens and their name
    or by a single hyphen and the flag character.

    The following option preset mechanisms are supported:
     - reading file $$/../share/default-test
     - reading file $HOME
     - reading file /old-home/bkorb/ag/ag/doc/.default_testrc
     - examining environment variables named DEFAULT_TEST_*

    The valid "verbose" option keywords are:
      silent quiet brief informative verbose
      or an integer from 0 through 4

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated by Bruce Korb on July 25, 2010 using texi2html 1.82.