Class CommandLineImperat

java.lang.Object
studio.mevera.imperat.BaseImperat<ConsoleCommandSource>
studio.mevera.imperat.CommandLineImperat
All Implemented Interfaces:
studio.mevera.imperat.AnnotationInjector<ConsoleCommandSource>, studio.mevera.imperat.CommandRegistrar<ConsoleCommandSource>, studio.mevera.imperat.events.EventListener, studio.mevera.imperat.events.EventPublisher, studio.mevera.imperat.Imperat<ConsoleCommandSource>, studio.mevera.imperat.SourceWrapper<ConsoleCommandSource>

public final class CommandLineImperat extends studio.mevera.imperat.BaseImperat<ConsoleCommandSource>
Main Imperat implementation for command-line interface applications. This class serves as the primary entry point for integrating the Imperat command framework with console-based applications, providing text-based command execution capabilities.

Key Features:

  • Simple console-based command execution
  • Text input/output through standard streams
  • Lightweight design for CLI applications
  • No dependency on server platforms
  • Suitable for standalone tools and utilities

Usage Example:


 public class MyCliApp {
     public static void main(String[] args) {
         CommandLineImperat imperat = CommandLineImperat.builder(System.in)
             .build();

         imperat.registerCommand(MyCommand.class);

         // Process commands from input stream
     }
 }
 
Since:
1.0
See Also:
  • Field Summary

    Fields inherited from class studio.mevera.imperat.BaseImperat

    config
  • Method Summary

    Modifier and Type
    Method
    Description
    builder(InputStream inputStream)
    Creates a new configuration builder for CommandLineImperat.
     
    void
    Dispatches the command-line from the input stream provided while using ConsoleLogger.SYSTEM for output.
    void
    execute(OutputStream outputStream)
    Deprecated.
    void
    execute(ConsoleLogger consoleLogger)
    Dispatches the command-line from the input stream provided
    Gets the platform object for this implementation.
    void
    Shuts down the platform and releases resources.
    Wraps a sender object into a ConsoleCommandSource.

    Methods inherited from class studio.mevera.imperat.BaseImperat

    autoComplete, canBeSender, config, debug, execute, execute, execute, execute, execute, getAnnotationParser, getCommand, getRegisteredCommands, getSubCommand, listen, publishEvent, registerAnnotationReplacer, registerAnnotations, registerCommand, registerCommand, registerSimpleCommand, removeListener, setAnnotationParser, unregisterAllCommands, unregisterCommand

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface studio.mevera.imperat.AnnotationInjector

    registerGlobalExceptionHandlers

    Methods inherited from interface studio.mevera.imperat.CommandRegistrar

    getCommand, registerCommands, registerCommands, registerCommands

    Methods inherited from interface studio.mevera.imperat.events.EventListener

    listen, listen
  • Method Details

    • builder

      public static CommandLineConfigBuilder builder(InputStream inputStream)
      Creates a new configuration builder for CommandLineImperat. This is the recommended way to create and configure a CommandLineImperat instance.
      Parameters:
      inputStream - the input stream for command line input (e.g., System.in)
      Returns:
      a new CommandLineConfigBuilder instance
    • getPlatform

      public InputStream getPlatform()
      Gets the platform object for this implementation. For CLI applications, this returns the input stream.
      Returns:
      the input stream used for command input
    • shutdownPlatform

      public void shutdownPlatform()
      Shuts down the platform and releases resources. For CLI applications, this closes the input stream.
    • createDummySender

      public ConsoleCommandSource createDummySender()
    • wrapSender

      public ConsoleCommandSource wrapSender(Object sender)
      Wraps a sender object into a ConsoleCommandSource. For CLI applications, all sources are console sources.
      Parameters:
      sender - the sender object (typically a ConsoleLogger)
      Returns:
      a new ConsoleCommandSource wrapping the sender
    • execute

      public void execute(ConsoleLogger consoleLogger)
      Dispatches the command-line from the input stream provided
      Parameters:
      consoleLogger - the console logger to write to
    • execute

      @Deprecated public void execute(OutputStream outputStream)
      Deprecated.
      Dispatches the command-line from the input stream provided
      Parameters:
      outputStream - the output stream/command-source origin
    • execute

      public void execute()
      Dispatches the command-line from the input stream provided while using ConsoleLogger.SYSTEM for output.