GraphMine

graphmine-core / io.github.sof3.graphmine.command.args / CommandArg

CommandArg

abstract class CommandArg<T : Any> : DelegateProvider<Overload, T>

Superclass of a command argument.

Constructors

<init> CommandArg()
Superclass of a command argument.

Properties

default var default: T?
Sets the default value of the command. Implicitly sets optional to true (even if the set value is null)
optional var optional: Boolean
Whether the command arg can be skipped
value lateinit var value: T
The received value of the argument

Functions

accept fun accept(parser: FormattedStringReader): Boolean
Reads the next value in the parser into the value for the argument.
default fun default(value: T): CommandArg<T>
Sets the default value of the command. Implicitly sets optional to true (even if the set value is null)
parse abstract fun parse(parser: FormattedStringReader): T?
Reads the next value in the parser into the value for the argument
provideDelegate open fun provideDelegate(thisRef: Overload, property: KProperty<*>): ReadOnlyProperty<Overload, T>

Inheritors

ClientArg class ClientArg : CommandArg<Client>
Accepts a client name
EnumArg class EnumArg<E : Enum<E>> : CommandArg<E>
Accepts a value that names one of the constants in the enum class
IntegerArg class IntegerArg : CommandArg<Int>
Accepts integer arguments.
NumberArg class NumberArg : CommandArg<Double>
Accepts any finite real-numeric arguments.
RawTextArg class RawTextArg : CommandArg<String>
Accepts the rest of the whole line literally
StringArg class StringArg : CommandArg<String>
Accepts the next value in the line. Multi-word arguments can be quoted by "" or their spaces escaped by \ before.