Class BaseCommand

java.lang.Object
ai.wanaku.cli.main.commands.BaseCommand
All Implemented Interfaces:
Callable<Integer>
Direct Known Subclasses:
Auth, AuthLogin, AuthLogout, AuthStatus, AuthToken, Capabilities, CapabilitiesBase, CapabilitiesCreate, CapabilitiesList, CapabilitiesShow, Completion, CompletionGenerate, DataStores, DataStoresAdd, DataStoresGet, DataStoresLabel, DataStoresLabelAdd, DataStoresLabelRemove, DataStoresList, DataStoresRemove, Forwards, ForwardsAdd, ForwardsList, ForwardsRemove, LabelExpressionMan, Man, NamespaceList, Namespaces, NamespacesLabel, NamespacesLabelAdd, NamespacesLabelRemove, Prompts, PromptsAdd, PromptsEdit, PromptsList, PromptsRemove, Resources, ResourcesExpose, ResourcesLabel, ResourcesLabelAdd, ResourcesLabelRemove, ResourcesList, ResourcesRemove, ResourcesShow, Start, StartBase, Tools, ToolsAdd, ToolsEdit, ToolSet, ToolSetAdd, ToolsGenerate, ToolsImport, ToolsLabel, ToolsLabelAdd, ToolsLabelRemove, ToolsList, ToolsRemove, ToolsShow

public abstract class BaseCommand extends Object implements Callable<Integer>
Abstract base class for all Wanaku CLI commands.

This class provides common functionality for all commands including:

  • Terminal and printer initialization for consistent output formatting
  • REST client initialization for communicating with the Wanaku service
  • Standard exit codes for success and error conditions
  • Help option handling

Subclasses must implement the doCall(Terminal, WanakuPrinter) method to define their specific command behavior.

  • Field Details

    • EXIT_OK

      public static final int EXIT_OK
      See Also:
    • EXIT_ERROR

      public static final int EXIT_ERROR
      See Also:
    • authTokenOverride

      protected String authTokenOverride
    • noAuth

      protected boolean noAuth
  • Constructor Details

    • BaseCommand

      public BaseCommand()
  • Method Details

    • initService

      protected static <T> T initService(Class<T> clazz, String host)
      Initializes and configures the REST client for communicating with the Wanaku service.

      Creates a properly configured Quarkus REST client builder with the specified host URL. The client is configured with appropriate timeouts and error handling for reliable communication with the Wanaku API endpoints.

      Type Parameters:
      T - the type of the service interface
      Parameters:
      clazz - the Class object representing the service interface
      host - the base URL of the Wanaku service API (must be a valid URI)
      Returns:
      a configured Service instance ready for API calls
      Throws:
      IllegalArgumentException - if the host URL is invalid or malformed
      NullPointerException - if host is null
    • initAuthenticatedService

      protected <T> T initAuthenticatedService(Class<T> clazz, String host)
    • initService

      protected static <T> T initService(Class<T> clazz, String host, String tokenOverride, boolean noAuth)
    • call

      public Integer call() throws Exception
      Specified by:
      call in interface Callable<Integer>
      Throws:
      Exception
    • doCall

      public abstract Integer doCall(org.jline.terminal.Terminal terminal, WanakuPrinter printer) throws Exception
      Throws:
      Exception