-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
KWCommands uses jitpack.io to provide binary classes, source and javadoc, thanks jitpack.io.
Adds the jitpack.io as repostory:
repositories {
maven { url 'https://jitpack.io' }
}
And then add KWCommands
as dependency.
dependencies {
compile 'com.github.JonathanxD:KWCommands:1.2.2-1'
}
Change 1.2.2-1 by the latest non-dev version available in jitpack.
If you don't care about concepts, go to KWCommands in practice to get things working, this is what you want, right?
KWCommands is a command line parsing and interface, designed not only for Java applications, but also for games (more with Minecraft in mind, but can be used in any kind of game).
Commands are represented by Command
class, the command class can be constructed by direct invocation of Command
constructor, using CommandBuilder
, using KWCommands Kotlin DSL, or using Reflection.
Arguments are strongly-type, validated and transformed during parsing (yes, during parsing). Arguments of boolean type is treated as options.
As said before, Arguments are strongly-typed, and types used in arguments are instances of ArgumentType
. ArgumentType was introduced to make Completation
viable for List and Map, also to make validation and transformation easy and simple.
Input is the base value that describes a input value in the input command string. The input value is commonly a String
represented by SingleInput
, but can be also a list of input value or a list of input value pair represented by ListInput
and MapInput
respectively.
Validator validates the input value before it go to Transformation, invalid elements are represented by ValidatedElement
class, which holds invalidated input value, the validator that made the validation, a Translatable text describing why the value is invalid, valid InputType
s (or since 1.3, the ArgumentType
).
Converts the input value into strong-typed value.
Returns all possibles values for the input, there are not rules to how to return these values because in 1.2, they only interface with user, which can easily understand what to do. There are rules only in 1.3, because of the Completion
system, but all provided classes follow these rules, you don't need to care about them.
Handles the command dispatch, can also by ArgumentHandler
to handle argument values (used by reflection to set fields).
Parses, validates and transform commands and arguments into Containers that can be thus dispatched at any time.
Manages super commands (children commands should be registered in super commands).
Dispatches commands, manages interception and post-dispatch handlers.
Creates commands from java classes (and instances), also manages ArgumentTypes
to be used to create strong-typed arguments.
Wrapper class that interfaces to a real printer (such as System.out
and System.err
).
A simple handler of ParseFail
and CommandResult
to print help.
All-in-one: Unifies common used instances and important parts to register, parse and dispatch commands.