class

Pegasus::Generators::Api::PegasusOptionParser(C, I)

Inherits Reference / Object

High-level class for constructing parser generators that are configurable from the command line.

This class uses Input to read a value of type I, then uses the registered FileGenerator instances to produce output via an OutputMode. All of these listed classes are registered with Crystal's native OptionParser, which serves to provide a user with configuration options.

The #output_file_names and #input_file_names hashes store the names of target output files and input files, respectively. These are updated by the Input and FileGenerators, as well as through user-supplied command-line options.

Constructors

new(input_method : Input(I), context : C = C.new)

Create a new PegasusOptionParser with the given input method and context.

Source

Instance methods

context

The context class (which must implement the add_option method) is included with the generator to store and retrieve parser-specific options. FileGenerator#context is used within a generator to access this value.

Source
file_gens

The list of registered file generators.

Source
input

The input gathered from the Input class. This starts uninitialized, but is set partway through #run.

Source
option_parser

The Crystal-native OptionParser used to actually print options to the console.

Source
output_file_names

Hash that stores the configured file names of the various FileGenerator instances, associated with their internal names. The file names are kept outside their generators so that two generators that depend on one another (like a source file including a header file) can know each other's names.

Source
run

Run the command line program, and the constructed generator.

Source