Class CoreCommandLineHelper

  • Direct Known Subclasses:
    UICommandLineHelper

    public class CoreCommandLineHelper
    extends java.lang.Object
    A helper class for command line options for GRIP.
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 to parse(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 arguments
        project - 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 arguments
        settingsProvider - the app's settings provider
        eventBus - the app's event bus