[silver:util:cmdargs]
Contents of [silver:util:cmdargs]
:
Defined in this grammar:
Contained in grammar [silver:util:cmdargs]
. Defined at silver/util/cmdargs/CmdArgs.sv line 11.
The type of lists of arguments given on the command line
Define a new production (as a cons cell for the CmdArgs list) for each flag given on the command line:
- For a flag that takes no arguments on the command line, define a production of type (CmdArgs ::= CmdArgs)
- For a flag that takes a single argument, define a production of type (CmdArgs ::= String CmdArgs)
- For a flag that takes more arguments, define a prodution of type (CmdArgs ::= [String] CmdArgs)
Contained in grammar [silver:util:cmdargs]
. Defined at silver/util/cmdargs/CmdArgs.sv line 17.
The remaining arguments from the commandline after parsing the flags
Contained in grammar [silver:util:cmdargs]
. Defined at silver/util/cmdargs/CmdArgs.sv line 21.
The errors from parsing commandline arguments
Contained in grammar [silver:util:cmdargs]
. Defined at silver/util/cmdargs/CmdArgs.sv line 52.
A specification of a flag for interpretCmdArgs at silver:util:cmdargs/CmdArgs.sv#73.
This uses the annotations-as-record pattern; when a proper record extension is merged, this should use that instead.
The name
is the string that should be present in the arguments list in
order for this flag to be recognized. In an example -o
flag, it would be
"-o"
.
The paramString
is a string describing the parameters the flag takes, for
use in the help text. In our running example, this might be
just("<file>")
. For flags that don’t take an argument, this should be
nothing()
.
The help
is a string describing the usage of the flag. Typically, this is
an English-language string that does not start with a capital letter, nor
end with a period. Often the imperative voice is used (e.g. “place the
output into
The flagParser
is the Flag
value used to handle the flag.
Putting these together, the FlagSpec
for our example -o
flag might look
something like:
flagSpec(name="-o", paramString=just("<file>"),
help="place the output into <file>", flagParser=option(outFlag))
Contained in grammar [silver:util:cmdargs]
. Defined at silver/util/cmdargs/CmdArgs.sv line 61.
The constructor of FlagSpec values.
Contained in grammar [silver:util:cmdargs]
. Defined at silver/util/cmdargs/CmdArgs.sv line 73.
WARNING!
The flag names in the flags parameter MUST start with a hyphen
Parameterflags
A list of FlagSpecs
Parameterinput
A list of strings, generally the commandline arguments
Return
The parsed list of arguments
Produce a parsed list of arguments using the given flags from the given input
Contained in grammar [silver:util:cmdargs]
. Defined at silver/util/cmdargs/CmdArgs.sv line 94.
Formats the –help text for the given FlagSpecs.
Contained in grammar [silver:util:cmdargs]
. Defined at silver/util/cmdargs/CmdArgs.sv line 142.
Parameterremaining
Commandline arguments remaining after parsing flags
For defining base, default values for any attributes on CmdArgs
Contained in grammar [silver:util:cmdargs]
. Defined at silver/util/cmdargs/CmdArgs.sv line 155.
Parametererrmsg
Error message
Only used when an error is encountered attempting to parse an option. One should always check for .cmdError.isJust BEFORE accessing any other attributes.
Contained in grammar [silver:util:cmdargs]
. Defined at silver/util/cmdargs/CmdArgs.sv line 166.
Flags are a representation of what to do with command line flags/options. It should not be necessary to define any new flags.
Contained in grammar [silver:util:cmdargs]
. Defined at silver/util/cmdargs/CmdArgs.sv line 180.
Parameterast
Production for handling this commandline option being given
In the terminology I’ve just made up, a ‘flag’ is a cmd line option with no parameters.
Contained in grammar [silver:util:cmdargs]
. Defined at silver/util/cmdargs/CmdArgs.sv line 193.
Parameterast
Production for handling this commandline option being given
In the terminology I’ve just made up, an ‘option’ is a cmd line option with one, single parameter.
Contained in grammar [silver:util:cmdargs]
. Defined at silver/util/cmdargs/CmdArgs.sv line 209.
Parametern
The number of arguments expected by the flag
Parameterast
Production for handling this commandline option being given
In the terminology I’ve just made up, ‘nOptions’ is a cmd line option with n parameters.