public final class Env extends Object
OptionProcessor
operates in. Streams can be
used to read and write data provided by the user. It is also possible
to obtain current user directory. In future this class may be extended
with additional new getters that will describe the operating environment
in greater detail.Modifier and Type | Method and Description |
---|---|
File |
getCurrentDirectory()
The directory relative file operations shall be relative to.
|
PrintStream |
getErrorStream()
Get an output stream to which error messages may be sent.
|
InputStream |
getInputStream()
Get an input stream that may supply additional data.
|
PrintStream |
getOutputStream()
Get an output stream to which data may be sent.
|
void |
usage()
Prints the help usage for current set of options.
|
void |
usage(OutputStream os)
Prints the help usage for current set of options.
|
public PrintStream getOutputStream()
public PrintStream getErrorStream()
public File getCurrentDirectory()
CommandLine
.public InputStream getInputStream()
public void usage()
usage
(Env.getOutputStream()
).public void usage(OutputStream os)
public class MyOptions implementsThis method finds associatedArgsProcessor
{@
Arg
(longName="help") public boolean help;@
Override
public void process(Env
env) { if (help) env.usage(env.Env.getErrorStream()
); } }
CommandLine
and calls its
usage
method to print
the help text to Env.getOutputStream()
.os
- output stream to write the output to