public final class Command extends Object
main(String[])
method accepts the following actions:
Each command can accepts an arbitrary amount of the following options:
help
Show a help overview. about
Show information about Apache SIS and system configuration. mime-type
Show MIME type for the given file. metadata
Show metadata information for the given file.
The
--format
The output format: xml
,wkt
,wkt1
ortext
.--locale
The locale to use for the command output. --timezone
The timezone for the dates to be formatted. --encoding
The encoding to use for the command output. --colors
Whether colorized output shall be enabled. --brief
Whether the output should contains only brief information. --verbose
Whether the output should contains more detailed information. --help
Lists the options available for a specific command.
--locale
, --timezone
and --encoding
options apply to the command output sent
to the standard output stream, but usually do not apply to the error messages sent
to the standard error stream. The reason is that command output may be targeted to
a client, while the error messages are usually for the operator.
org.apache.sis.console
package javadoc for more information.Defined in the sis-console
module
Modifier and Type | Field and Description |
---|---|
static int |
INVALID_ARGUMENT_EXIT_CODE
The code given to
System.exit(int) when the program failed because of an illegal user argument. |
static int |
INVALID_COMMAND_EXIT_CODE
The code given to
System.exit(int) when the program failed because of a unknown sub-command. |
static int |
INVALID_OPTION_EXIT_CODE
The code given to
System.exit(int) when the program failed because of a unknown option. |
static int |
IO_EXCEPTION_EXIT_CODE
The code given to
System.exit(int) when the program failed because of an IOException . |
static int |
OTHER_ERROR_EXIT_CODE
The code given to
System.exit(int) when the program failed for a reason
other than the ones enumerated in the above constants. |
static int |
SQL_EXCEPTION_EXIT_CODE
The code given to
System.exit(int) when the program failed because of an SQLException . |
static int |
UNKNOWN_STORAGE_EXIT_CODE
The code given to
System.exit(int) when a file given in argument uses an unknown file format. |
Modifier | Constructor and Description |
---|---|
protected |
Command(String[] args)
Creates a new command for the given arguments.
|
Modifier and Type | Method and Description |
---|---|
static int |
exitCodeFor(Throwable cause)
Returns the exit code for the given exception, or 0 if unknown.
|
static void |
main(String[] args)
Prints the information to the standard output stream.
|
int |
run()
Runs the command.
|
public static final int INVALID_COMMAND_EXIT_CODE
System.exit(int)
when the program failed because of a unknown sub-command.public static final int INVALID_OPTION_EXIT_CODE
System.exit(int)
when the program failed because of a unknown option.
The set of valid options depend on the sub-command to execute.public static final int INVALID_ARGUMENT_EXIT_CODE
System.exit(int)
when the program failed because of an illegal user argument.
The user arguments are everything which is not a command name or an option. They are typically file names,
but can occasionally be other types like URL.public static final int UNKNOWN_STORAGE_EXIT_CODE
System.exit(int)
when a file given in argument uses an unknown file format.public static final int IO_EXCEPTION_EXIT_CODE
System.exit(int)
when the program failed because of an IOException
.public static final int SQL_EXCEPTION_EXIT_CODE
System.exit(int)
when the program failed because of an SQLException
.public static final int OTHER_ERROR_EXIT_CODE
System.exit(int)
when the program failed for a reason
other than the ones enumerated in the above constants.protected Command(String[] args) throws InvalidCommandException, InvalidOptionException
args
- The command-line arguments.InvalidCommandException
- If an invalid command has been given.InvalidOptionException
- If the given arguments contain an invalid option.public int run() throws Exception
exitCodeFor(Throwable)
method.Exception
- If an error occurred during the command execution. This is typically, but not limited, to
IOException
, SQLException
, DataStoreException
or TransformException
.public static int exitCodeFor(Throwable cause)
*_EXIT_CODE
constant is found.cause
- The exception for which to get the exit code.*_EXIT_CODE
constant, or OTHER_ERROR_EXIT_CODE
if unknown.public static void main(String[] args)
args
- Command-line options.Copyright © 2010–2015 The Apache Software Foundation. All rights reserved.