Class MultiCommand

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class MultiCommand
    extends Command
    A cli tool which is made up of multiple subcommands.
    • Constructor Summary

      Constructors 
      Constructor Description
      MultiCommand​(java.lang.String description, java.lang.Runnable beforeMain)
      Construct the multi-command with the specified command description and runnable to execute before main is invoked.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      protected void execute​(Terminal terminal, joptsimple.OptionSet options)
      Executes this command.
      protected void printAdditionalHelp​(Terminal terminal)
      Prints additional help information, specific to the command
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • subcommands

        protected final java.util.Map<java.lang.String,​Command> subcommands
    • Constructor Detail

      • MultiCommand

        public MultiCommand​(java.lang.String description,
                            java.lang.Runnable beforeMain)
        Construct the multi-command with the specified command description and runnable to execute before main is invoked.
        Parameters:
        description - the multi-command description
        beforeMain - the before-main runnable
    • Method Detail

      • printAdditionalHelp

        protected void printAdditionalHelp​(Terminal terminal)
        Description copied from class: Command
        Prints additional help information, specific to the command
        Overrides:
        printAdditionalHelp in class Command
      • execute

        protected void execute​(Terminal terminal,
                               joptsimple.OptionSet options)
                        throws java.lang.Exception
        Description copied from class: Command
        Executes this command. Any runtime user errors (like an input file that does not exist), should throw a UserException.
        Specified by:
        execute in class Command
        Throws:
        java.lang.Exception
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class Command
        Throws:
        java.io.IOException