DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(guile.info.gz) getopt-long Reference

Info Catalog (guile.info.gz) Command Line Format (guile.info.gz) getopt-long (guile.info.gz) option-ref Reference
 
 10.2.4 Reference Documentation for `getopt-long'
 ------------------------------------------------
 
  -- Scheme Procedure: getopt-long args grammar
      Parse the command line given in ARGS (which must be a list of
      strings) according to the option specification GRAMMAR.
 
      The GRAMMAR argument is expected to be a list of this form:
 
      `((OPTION (PROPERTY VALUE) ...) ...)'
 
      where each OPTION is a symbol denoting the long option, but
      without the two leading dashes (e.g. `version' if the option is
      called `--version').
 
      For each option, there may be list of arbitrarily many
      property/value pairs.  The order of the pairs is not important,
      but every property may only appear once in the property list.  The
      following table lists the possible properties:
 
     `(single-char CHAR)'
           Accept `-CHAR' as a single-character equivalent to
           `--OPTION'.  This is how to specify traditional Unix-style
           flags.
 
     `(required? BOOL)'
           If BOOL is true, the option is required.  `getopt-long' will
           raise an error if it is not found in ARGS.
 
     `(value BOOL)'
           If BOOL is `#t', the option accepts a value; if it is `#f',
           it does not; and if it is the symbol `optional', the option
           may appear in ARGS with or without a value.
 
     `(predicate FUNC)'
           If the option accepts a value (i.e. you specified `(value
           #t)' for this option), then `getopt-long' will apply FUNC to
           the value, and throw an exception if it returns `#f'.  FUNC
           should be a procedure which accepts a string and returns a
           boolean value; you may need to use quasiquotes to get it into
           GRAMMAR.
 
 `getopt-long''s ARGS parameter is expected to be a list of strings like
 the one returned by `command-line', with the first element being the
 name of the command.  Therefore `getopt-long' ignores the first element
 in ARGS and starts argument interpretation with the second element.
 
    `getopt-long' signals an error if any of the following conditions
 hold.
 
    * The option grammar has an invalid syntax.
 
    * One of the options in the argument list was not specified by the
      grammar.
 
    * A required option is omitted.
 
    * An option which requires an argument did not get one.
 
    * An option that doesn't accept an argument does get one (this can
      only happen using the long option `--opt=VALUE' syntax).
 
    * An option predicate fails.
 
Info Catalog (guile.info.gz) Command Line Format (guile.info.gz) getopt-long (guile.info.gz) option-ref Reference
automatically generated byinfo2html