Class Command

    • Constructor Detail

      • Command

        protected Command​(String name,
                          String description)
        Create a new command with the given name and description.
        Parameters:
        name - the name of the command, used for command line invocation
        description - a description of the command's purpose
    • Method Detail

      • getName

        public final String getName()
        Returns the command's name.
        Returns:
        the command's name
      • getDescription

        public final String getDescription()
        Returns the command's description.
        Returns:
        the command's description
      • configure

        public abstract void configure​(net.sourceforge.argparse4j.inf.Subparser subparser)
        Configure the command's Subparser.
        Parameters:
        subparser - the Subparser specific to the command
      • run

        public abstract void run​(Bootstrap<?> bootstrap,
                                 net.sourceforge.argparse4j.inf.Namespace namespace)
                          throws Exception
        Executes when the user runs this specific command.
        Parameters:
        bootstrap - the bootstrap bootstrap
        namespace - the parsed command line namespace
        Throws:
        Exception - if something goes wrong
      • onError

        public void onError​(Cli cli,
                            net.sourceforge.argparse4j.inf.Namespace namespace,
                            Throwable e)
        Method is called if there is an issue parsing configuration, setting up the environment, or running the command itself. The default is printing the stacktrace to facilitate debugging, but can be customized per command.
        Parameters:
        cli - contains the streams for stdout and stderr
        namespace - the parsed arguments from the commandline
        e - The exception that was thrown when setting up or running the command