public interface ArgsParser extends org.refcodes.mixin.mixins.NameAccessor.NameBuilder<ArgsParser>, org.refcodes.mixin.mixins.DescriptionAccessor.DescriptionBuilder<ArgsParser>
ArgsParser
provides means for parsing command line arguments and
constructing a command line utility's help output.Modifier and Type | Method and Description |
---|---|
List<? extends Operand<?>> |
evalArgs(String[] aArgs)
Evaluates the provided command line arguments and determines the
according values by evaluating the root
Condition . |
Condition |
getRootCondition()
The root condition is the starting point node of a
Syntaxable
hierarchy to be traversed when determining the syntax for command line
arguments or when evaluating the command line arguments. |
void |
printBanner()
Prints the banner; the banner most probably is an ASCII art text block
which's look depends strongly on the taste of the author implementing
this interface.
|
void |
printCopyrightNote()
Prints the copyright note as specified by the
setCopyrightNote(String) method; with regards to to the console
width as specified by the setConsoleWidth(int) method. |
void |
printDescription()
Prints the description as set by the
DescriptionAccessor.DescriptionBuilder.setDescription(String)
method with regards to the console width as specified by the
setConsoleWidth(int) method. |
void |
printHelp()
Prints the help to the standard output specified by the
setStandardOut(PrintStream) method. |
void |
printLicenseNote()
Prints the license note as specified by the
setLicenseNote(String) method; with regards to to the console
width as specified by the setConsoleWidth(int) method. |
void |
printLn()
Prints an empty line / a line break.
|
void |
printLn(String aLine)
Prints the given line with regards to to the console width as specified
by the
setConsoleWidth(int) method. |
void |
printOptions()
Prints the
Option s (short- and the long-options), the
Switch es and the Operator and their description with
regards to the console width as specified by the
setConsoleWidth(int) method. |
void |
printSeparatorLn()
Prints a separator line using the separator character as specified by the
setSeparatorChar(char) method; with regards to to the console
width as specified by the setConsoleWidth(int) method. |
void |
printUsage()
Prints the syntax as retrieved by the root
Condition# with
regards to the SyntaxNotation set by the
setSyntaxNotation(SyntaxNotation) method; making use of the
usage label as passed by the setUsageLabel(String) method. |
ArgsParser |
setConsoleWidth(int aConsoleWidth)
Set the console with and make other adjustments with the result (with
regards to the builder pattern).
|
ArgsParser |
setCopyrightNote(String aCopyrightNote)
Set the copyright note used by the
printHelp() method when
writing out the copyright claim and make other adjustments with the
result (with regards to the builder pattern). |
ArgsParser |
setLicenseNote(String aLicenseNote)
Set the license note used by the
printHelp() method when writing
out the licensing conditions and make other adjustments with the result
(with regards to the builder pattern). |
ArgsParser |
setLineBreak(String aLineBreak)
Set the console's line break and make other adjustments with the result
(with regards to the builder pattern).
|
ArgsParser |
setSeparatorChar(char aSeparatorChar)
Set the character to be used when printing a separator line with the
printSeparatorLn() method. |
ArgsParser |
setStandardOut(PrintStream aStandardOut)
Set the standard out
PrintStream and make other adjustments with
the result (with regards to the builder pattern). |
ArgsParser |
setSyntaxNotation(SyntaxNotation aSyntaxNotation)
Set the
SyntaxNotation and make other adjustments with the result
(with regards to the builder pattern). |
ArgsParser |
setUsageLabel(String aUsageLabel)
Set the usage label used by the
printHelp() method when writing
out the syntax and make other adjustments with the result (with regards
to the builder pattern). |
List<? extends Operand<?>> evalArgs(String[] aArgs) throws UnknownArgsException, AmbiguousArgsException, SuperfluousArgsException, ParseArgsException
Condition
.
In case of parsing failure, an according exception is thrown.
ATTENTION: This method tests(!) for superfluous command line arguments
being passed; e.g. command line arguments not being evaluated by any of
the Syntaxable
instance being traversed starting at the root
Condition
will be reported. Business logic therefore should
invoke this root node's evalArgs(String[])
method instead of a
Condition
's Syntaxable.parseArgs(String[])
method; as
ignoring superfluous command line arguments will cause unexpected
behavior from the point of view of the invoker.aArgs
- The command line arguments to be evaluated.Operand
interfaces or its sub-types.UnknownArgsException
- Thrown in case not one command line argument
matched regarding the provided args vs. the expected args.AmbiguousArgsException
- Thrown in case at least one command line
argument is ambiguous regarding expected args vs. provided args.SuperfluousArgsException
- Thrown in case there were arguments
found not being used (superfluous arguments).ParseArgsException
- Thrown in case the provided command line
arguments do not respect the required syntax or cannot be
converted to the required typeCondition getRootCondition()
Syntaxable
hierarchy to be traversed when determining the syntax for command line
arguments or when evaluating the command line arguments.Condition
in which's syntax this parser is
based.ArgsParser setLineBreak(String aLineBreak)
SystemUtility.getLineBreak()()
value.aConsoleWidth
- The width to set.ArgsParser setConsoleWidth(int aConsoleWidth)
SystemUtility.getConsoleWidth()
value.aConsoleWidth
- The width to set.ArgsParser setStandardOut(PrintStream aStandardOut)
PrintStream
and make other adjustments with
the result (with regards to the builder pattern).aStandardOut
- The standard out PrintStream
to set.ArgsParser setSyntaxNotation(SyntaxNotation aSyntaxNotation)
SyntaxNotation
and make other adjustments with the result
(with regards to the builder pattern).aSyntaxNotation
- The SyntaxNotation
to set.ArgsParser setLicenseNote(String aLicenseNote)
printHelp()
method when writing
out the licensing conditions and make other adjustments with the result
(with regards to the builder pattern).aLicenseNote
- The license note printed out by the
printHelp()
method.ArgsParser setUsageLabel(String aUsageLabel)
printHelp()
method when writing
out the syntax and make other adjustments with the result (with regards
to the builder pattern).aUsageLabel
- The usage label printed out by the
printHelp()
method.ArgsParser setCopyrightNote(String aCopyrightNote)
printHelp()
method when
writing out the copyright claim and make other adjustments with the
result (with regards to the builder pattern).aCopyrightNote
- The license note printed out by the
printHelp()
method.ArgsParser setSeparatorChar(char aSeparatorChar)
printSeparatorLn()
method.aSeparatorChar
- The character used by the
printSeparatorLn()
method when printing out the line of
characters..void printBanner()
void printLicenseNote()
setLicenseNote(String)
method; with regards to to the console
width as specified by the setConsoleWidth(int)
method.void printUsage()
Condition#
with
regards to the SyntaxNotation
set by the
setSyntaxNotation(SyntaxNotation)
method; making use of the
usage label as passed by the setUsageLabel(String)
method.void printDescription()
DescriptionAccessor.DescriptionBuilder.setDescription(String)
method with regards to the console width as specified by the
setConsoleWidth(int)
method.void printOptions()
Option
s (short- and the long-options), the
Switch
es and the Operator
and their description with
regards to the console width as specified by the
setConsoleWidth(int)
method.void printCopyrightNote()
setCopyrightNote(String)
method; with regards to to the console
width as specified by the setConsoleWidth(int)
method.void printSeparatorLn()
setSeparatorChar(char)
method; with regards to to the console
width as specified by the setConsoleWidth(int)
method.void printLn(String aLine)
setConsoleWidth(int)
method.void printLn()
void printHelp()
setStandardOut(PrintStream)
method. This method can make use of
the more atomic methods printBanner()
, printUsage()
,
printDescription()
, printOptions()
or
printSeparatorLn()
to print a help text which's look depends
strongly on the taste of the author implementing this interface. In case
you dislike the implementing author's taste, feel free to overwrite this
method and compose your own help text from the building blocks such as
printBanner()
, printUsage()
,
printDescription()
, printOptions()
or
printSeparatorLn()
Copyright © 2015. All rights reserved.