Object
Command
Command line interface for Apache SIS. The
main(String[]) method accepts the following actions:
Each command can accepts some of the following options:
Supported command-line actions helpShow a help overview. aboutShow information about Apache SIS and system configuration. mime-typeShow MIME type for the given file. metadataShow metadata information for the given file. crsShow Coordinate Reference System information for the given file or code. identifierShow identifiers for metadata and referencing systems in the given file. transformConvert or transform coordinates from given source CRS to target CRS.
The
Supported command-line options --sourceCRSThe Coordinate Reference System of input data. --targetCRSThe Coordinate Reference System of output data. --formatThe output format: xml,wkt,wkt1ortext.--localeThe locale to use for the command output. --timezoneThe timezone for the dates to be formatted. --encodingThe encoding to use for the command outputs and some inputs. --colorsWhether colorized output shall be enabled. --briefWhether the output should contain only brief information. --verboseWhether the output should contain more detailed information. --debugPrints full stack trace in case of failure. --helpLists 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.
SIS installation on remote machines
Some sub-commands can operate on SIS installation on remote machines, provided that remote access has been enabled at the Java Virtual Machine startup time. See package javadoc for more information.- Since:
- 0.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe code given toSystem.exit(int)when the program failed because of an illegal user argument.static final intThe code given toSystem.exit(int)when the program failed because of a unknown sub-command.static final intThe code given toSystem.exit(int)when the program failed because of a unknown option.static final intThe code given toSystem.exit(int)when the program failed because of anIOException.static final intThe code given toSystem.exit(int)when the program failed for a reason other than the ones enumerated in the above constants.static final intThe code given toSystem.exit(int)when the program failed because of anSQLException.static final intThe code given toSystem.exit(int)when a file given in argument uses an unknown file format. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intexitCodeFor(Throwable cause) Returns the exit code for the given exception, or 0 if unknown.static voidPrints the information to the standard output stream.intrun()Runs the command.
-
Field Details
-
INVALID_COMMAND_EXIT_CODE
public static final int INVALID_COMMAND_EXIT_CODEThe code given toSystem.exit(int)when the program failed because of a unknown sub-command.- See Also:
-
INVALID_OPTION_EXIT_CODE
public static final int INVALID_OPTION_EXIT_CODEThe code given toSystem.exit(int)when the program failed because of a unknown option. The set of valid options depend on the sub-command to execute.- See Also:
-
INVALID_ARGUMENT_EXIT_CODE
public static final int INVALID_ARGUMENT_EXIT_CODEThe code given toSystem.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.- See Also:
-
UNKNOWN_STORAGE_EXIT_CODE
public static final int UNKNOWN_STORAGE_EXIT_CODEThe code given toSystem.exit(int)when a file given in argument uses an unknown file format.- See Also:
-
IO_EXCEPTION_EXIT_CODE
public static final int IO_EXCEPTION_EXIT_CODEThe code given toSystem.exit(int)when the program failed because of anIOException.- See Also:
-
SQL_EXCEPTION_EXIT_CODE
public static final int SQL_EXCEPTION_EXIT_CODEThe code given toSystem.exit(int)when the program failed because of anSQLException.- See Also:
-
OTHER_ERROR_EXIT_CODE
public static final int OTHER_ERROR_EXIT_CODEThe code given toSystem.exit(int)when the program failed for a reason other than the ones enumerated in the above constants.- See Also:
-
-
Constructor Details
-
Command
Creates a new command for the given arguments. The first value in the given array which is not an option is taken as the command name. All other values are options or filenames.- Parameters:
args- the command-line arguments.- Throws:
InvalidCommandException- if an invalid command has been given.InvalidOptionException- if the given arguments contain an invalid option.
-
-
Method Details
-
run
Runs the command. If an exception occurs, then the exception message is sent to the error output stream before to be thrown. Callers can map the exception to a system exit code by theexitCodeFor(Throwable)method.- Returns:
- 0 on success, or an exit code if the command failed for a reason other than a Java exception.
- Throws:
Exception- if an error occurred during the command execution. This is typically, but not limited, toIOException,SQLException,DataStoreExceptionorTransformException.
-
exitCodeFor
Returns the exit code for the given exception, or 0 if unknown. This method iterates through the causes until an exception matching a*_EXIT_CODEconstant is found.- Parameters:
cause- the exception for which to get the exit code.- Returns:
- the exit code as one of the
*_EXIT_CODEconstant, orOTHER_ERROR_EXIT_CODEif unknown.
-
main
Prints the information to the standard output stream.- Parameters:
args- command-line options.
-