Package studio.mevera.imperat
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 TypeMethodDescriptionstatic CommandLineConfigBuilderbuilder(InputStream inputStream) Creates a new configuration builder for CommandLineImperat.voidexecute()Dispatches the command-line from the input stream provided while usingConsoleLogger.SYSTEMfor output.voidexecute(OutputStream outputStream) Deprecated.voidexecute(ConsoleLogger consoleLogger) Dispatches the command-line from the input stream providedGets the platform object for this implementation.voidShuts down the platform and releases resources.wrapSender(Object sender) 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, unregisterCommandMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface studio.mevera.imperat.AnnotationInjector
registerGlobalExceptionHandlersMethods inherited from interface studio.mevera.imperat.CommandRegistrar
getCommand, registerCommands, registerCommands, registerCommandsMethods inherited from interface studio.mevera.imperat.events.EventListener
listen, listen
-
Method Details
-
builder
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
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
-
wrapSender
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
Dispatches the command-line from the input stream provided- Parameters:
consoleLogger- the console logger to write to
-
execute
Deprecated.Useexecute(ConsoleLogger)insteadDispatches 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 usingConsoleLogger.SYSTEMfor output.
-
execute(ConsoleLogger)instead