Class ToolBase.ConfiguredCliTool<T extends Annotation>

java.lang.Object
io.bdeploy.common.cli.ToolBase.CliTool
io.bdeploy.common.cli.ToolBase.ConfiguredCliTool<T>
Direct Known Subclasses:
DiscUsageTool, ExportTool, FsckTool, ImportTool, InitTool, LocalLoginTool, PruneTool, RemoteServiceTool, ServeTool, TokenTool, TreeTool
Enclosing class:
ToolBase

public abstract static class ToolBase.ConfiguredCliTool<T extends Annotation> extends ToolBase.CliTool
Base class for tools that accept additional configuration.
See Also:
  • Constructor Details

    • ConfiguredCliTool

      protected ConfiguredCliTool(Class<T> configClass)
      Parameters:
      configClass - the configuration annotation class to use.
  • Method Details

    • getPrimaryConfigClass

      protected Class<? extends Annotation> getPrimaryConfigClass()
      Returns:
      the type of the primary configuration annotation (the one passed in the constructor).
    • getConfigsForHelp

      protected List<Class<? extends Annotation>> getConfigsForHelp()
      Returns:
      all Annotations for which to render help output.
    • getConfig

      protected <X extends Annotation> X getConfig(Class<X> clazz)
      Create a specific configuration from the underlying raw configuration using the given annotation.
    • getRawConfiguration

      protected Configuration getRawConfiguration()
      Returns:
      the underlying raw configuration.
    • run

      public final RenderableResult run()
      Description copied from class: ToolBase.CliTool
      Execute the tool.
      Specified by:
      run in class ToolBase.CliTool
    • helpAndFailIfMissing

      protected void helpAndFailIfMissing(Object argument, String message)
      Parameters:
      argument - display help text and fail the tool if the argument is null.
    • helpAndFail

      protected void helpAndFail(String message)
      Display the help text and fail the tool (System.exit(1)).
    • run

      protected abstract RenderableResult run(T config)
      Run the configured tool using configuration from the command line.
      Parameters:
      config - the configuration instance for the tool.