Package edu.wpi.grip.core
Class CoreCommandLineHelper
- java.lang.Object
-
- edu.wpi.grip.core.CoreCommandLineHelper
-
- Direct Known Subclasses:
UICommandLineHelper
public class CoreCommandLineHelper extends java.lang.Object
A helper class for command line options for GRIP.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
FILE_OPTION
static java.lang.String
HELP_OPTION
static java.lang.String
PORT_OPTION
static java.lang.String
VERSION_OPTION
-
Constructor Summary
Constructors Modifier Constructor Description CoreCommandLineHelper()
Creates a new core commandline helper with the standard options.protected
CoreCommandLineHelper(org.apache.commons.cli.Option... additionalOptions)
Creates a command line helper with all the standard options, plus any additional options required by subclasses.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
loadFile(org.apache.commons.cli.CommandLine args, Project project)
Tries to load a file from the command line arguments.org.apache.commons.cli.CommandLine
parse(java.lang.String... args)
Parses an array of command line arguments.org.apache.commons.cli.CommandLine
parse(java.util.List<java.lang.String> args)
Parses a list of command line arguments.void
setServerPort(org.apache.commons.cli.CommandLine args, SettingsProvider settingsProvider, com.google.common.eventbus.EventBus eventBus)
Tries to set the internal server port from the command line arguments.
-
-
-
Field Detail
-
FILE_OPTION
public static final java.lang.String FILE_OPTION
- See Also:
- Constant Field Values
-
PORT_OPTION
public static final java.lang.String PORT_OPTION
- See Also:
- Constant Field Values
-
HELP_OPTION
public static final java.lang.String HELP_OPTION
- See Also:
- Constant Field Values
-
VERSION_OPTION
public static final java.lang.String VERSION_OPTION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CoreCommandLineHelper
public CoreCommandLineHelper()
Creates a new core commandline helper with the standard options.
-
CoreCommandLineHelper
protected CoreCommandLineHelper(org.apache.commons.cli.Option... additionalOptions)
Creates a command line helper with all the standard options, plus any additional options required by subclasses.- Parameters:
additionalOptions
- additional command line arguments
-
-
Method Detail
-
parse
public org.apache.commons.cli.CommandLine parse(java.lang.String... args)
Parses an array of command line arguments. If there are unknown arguments or the arguments are otherwise malformed, a help message will be printed and the application will exit without returning from this method. This will also occur if the help option is specified.- Parameters:
args
- the command line arguments to parse- Returns:
- a CommandLine object that can be queried for command line options and their values
-
parse
public org.apache.commons.cli.CommandLine parse(java.util.List<java.lang.String> args)
Parses a list of command line arguments. This coverts the list to an array and passes it toparse(String[])
.- See Also:
parse(String[])
-
loadFile
public void loadFile(org.apache.commons.cli.CommandLine args, Project project) throws java.io.IOException
Tries to load a file from the command line arguments. Does nothing if no file was specified.- Parameters:
args
- the parsed command line argumentsproject
- the project to load the file into- Throws:
java.io.IOException
- if the file couldn't be loaded
-
setServerPort
public void setServerPort(org.apache.commons.cli.CommandLine args, SettingsProvider settingsProvider, com.google.common.eventbus.EventBus eventBus)
Tries to set the internal server port from the command line arguments. Does nothing if no port was specified.- Parameters:
args
- the parsed command line argumentssettingsProvider
- the app's settings providereventBus
- the app's event bus
-
-