Package be.panako.cli

Class Application

java.lang.Object
be.panako.cli.Application
Direct Known Subclasses:
Clear, Configuration, Delete, Load, Monitor, Play, Print, Query, Resolve, Same, Stats, Store

public abstract class Application extends Object
Application is the abstract base class of applications with a command line interface.
  • Constructor Details

    • Application

      public Application()
  • Method Details

    • run

      public abstract void run(String... args)
      Parameters:
      args - The arguments to start the program.
    • name

      public final String name()
      The name of the application is the class lower case class name.
      Returns:
      The name of the application.
    • description

      public abstract String description()
      Returns:
      The description of the application. What does it do?
    • synopsis

      public abstract String synopsis()
      The synopsis is a short description of the required or optional arguments.
      Returns:
      The command line synopsis.
    • needsStorage

      public abstract boolean needsStorage()
      Returns:
      True if this application needs the storage, false otherwise.
    • getFilesFromArguments

      public List<File> getFilesFromArguments(String[] arguments)
      Returns a list of exiting (checked) files in the argument list. If a text (with txt extension) file is found its contents is read and each line in the file interpreted as an absolute path to a file.
      Parameters:
      arguments - the list of command line arguments
      Returns:
      A list of checked file.
    • checkFile

      protected boolean checkFile(String file)
      Checks if a file exists and can be read.
      Parameters:
      file - The file to check.
      Returns:
      True if the file exists and can be read. False otherwise.
    • availableProcessors

      public static int availableProcessors()
      Checks the configuration and returns either the number of configured number of available processors to use or the maximum number of available processors if the configured value is zero or negative.
      Returns:
      Either the number of configured number of available processors to use or the maximum number of available processors if the configured value is zero or negative.
    • hasArgument

      protected boolean hasArgument(String argument, String... strings)
      Checks if an argument is present in a list of arguments.
      Parameters:
      argument - The argument to check for.
      strings - The given arguments.
      Returns:
      True if the argument is in the given list. Case is ignored. False otherwise.
    • getIntegerOption

      protected int getIntegerOption(String option, int defaultValue, String... arguments)
      Parameters:
      option - The argument e.g. "-n".
      arguments - The list of arguments to search in.
      Returns:
      The integer found or the default value.
    • getOption

      protected String getOption(String option, String defaultValue, String... arguments)
      Return the value of an option. E.g. calling this method with option "-n" and default value 20 on the following panako stats --n 10 returns 10.
      Parameters:
      option - The option to look for
      defaultValue - The default value
      arguments - The arguments to search in
      Returns:
      The value of the option, or the provided default.
    • writesToStorage

      public abstract boolean writesToStorage()
      Returns:
      true if this application writes to storage.
    • printHelp

      public void printHelp()