class Pegasus::Generators::Api::PegasusOptionParser(C, I)
- Pegasus::Generators::Api::PegasusOptionParser(C, I)
- Reference
- Object
Overview
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 FileGenerator
s, as well
as through user-supplied command-line options.
Defined in:
generators/generators.crConstructors
-
.new(input_method : Input(I), context : C = C.new)
Create a new
PegasusOptionParser
with the given input method and context.
Instance Method Summary
-
#context : C
The context class (which must implement the
add_option
method) is included with the generator to store and retrieve parser-specific options. -
#file_gens : Array(FileGenerator(C, I))
The list of registered file generators.
-
#input : I | Nil
The input gathered from the
Input
class. -
#option_parser : OptionParser
The Crystal-native
OptionParser
used to actually print options to the console. -
#output_file_names : Hash(String, String)
Hash that stores the configured file names of the various
FileGenerator
instances, associated with their internal names. -
#run
Run the command line program, and the constructed generator.
Constructor Detail
Create a new PegasusOptionParser
with the given input method and context.
Instance Method Detail
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.
The input gathered from the Input
class. This starts
uninitialized, but is set partway through #run
.
The Crystal-native OptionParser
used to actually
print options to the console.
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.