Next: , Previous: Executable Modules, Up: Miscellaneous Tools


13.4 Using HVQC-MAIN in Executable Modules

The previous section described the basic requirements for writing an executable module. This section presents the convenience function HVQC-MAIN exported from the (scripts PROGRAM) module, part of the Guile distribution.

The letters HVQC stand for Help, Version, Query-options and Callback, respectively; these are the standard services provided by HVQC-MAIN. The first two services do not involve callback procedures, while the last two do.

These services are typically not useful when the executable module is used from a Scheme program (as opposed to being invoked from the shell), so the common construction is to use it in the entry point, and arrange for (scripts PROGRAM) to load only if needed via an #:autoload stanza in the define-module form. For example:

     (define-module (my modules my-prog)
       #:autoload (scripts PROGRAM) (HVQC-MAIN)
       ...)
— Scheme Procedure: HVQC-MAIN args callback . config

Parse and handle args, a list of strings, for --help, --version, getopt-style command-line options processing and eventual application of callback, a procedure with one of two signatures (see below), all based on config, a list of zero or more key-value pairs for configuring the behavior of HVQC-MAIN. Recognized keys are: package, version, usage and option-spec.

Specifically, HVQC-MAIN does these actions:

There are many examples of HVQC-MAIN usage in the Guile distribution: all the (scripts FOO) modules use it in varying ways. The easiest way is to browse the code:

     $ guile-tools                    # to see a list of programs
     $ guile-tools PROGRAM --help     # to see PROGRAM's help
     $ guile-tools PROGRAM --version  # to see PROGRAM's version
     $ guile-tools --source PROGRAM   # to see PROGRAM's source

Happy toolsmithing!