Skip to content

Getting Started

Jonathan edited this page Nov 27, 2017 · 3 revisions

Dependency

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.

KWCommands in practice

If you don't care about concepts, go to KWCommands in practice to get things working, this is what you want, right?

KWCommands

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

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

Arguments are strongly-type, validated and transformed during parsing (yes, during parsing). Arguments of boolean type is treated as options.

ArgumentType (1.3 milestone)

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

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

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 InputTypes (or since 1.3, the ArgumentType).

Transformer

Converts the input value into strong-typed value.

Possibilities

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.

Handler

Handles the command dispatch, can also by ArgumentHandler to handle argument values (used by reflection to set fields).

CommandParser

Parses, validates and transform commands and arguments into Containers that can be thus dispatched at any time.

CommandManager

Manages super commands (children commands should be registered in super commands).

CommandDispatcher

Dispatches commands, manages interception and post-dispatch handlers.

ReflectionEnvironment

Creates commands from java classes (and instances), also manages ArgumentTypes to be used to create strong-typed arguments.

Printer

Wrapper class that interfaces to a real printer (such as System.out and System.err).

HelpInfoHandler

A simple handler of ParseFail and CommandResult to print help.

AIO

All-in-one: Unifies common used instances and important parts to register, parse and dispatch commands.

Next

KWCommands in practice.