CommanderCommand

class CommanderCommand(val parent: CommanderCommand? = null, val name: String, val aliases: Array<String> = arrayOf(), val description: String? = null, val arguments: MutableList<CommanderArgument> = mutableListOf(), val options: MutableList<CommanderOption> = mutableListOf(), val commands: MutableList<CommanderCommand> = mutableListOf(), var action: CommanderCommandAction? = null)(source)

A class that represents a command line interface command

Since

0.1.0

Parameters

parent

The parent command

name

The name of the command

aliases

The aliases of the command

description

The description of the command

arguments

The arguments of the command

options

The options of the command

commands

The subcommands of the command

action

The action of the command

Constructors

Link copied to clipboard
constructor(parent: CommanderCommand? = null, name: String, aliases: Array<String> = arrayOf(), description: String? = null, arguments: MutableList<CommanderArgument> = mutableListOf(), options: MutableList<CommanderOption> = mutableListOf(), commands: MutableList<CommanderCommand> = mutableListOf(), action: CommanderCommandAction? = null)

Properties

Link copied to clipboard

The action of the command

Link copied to clipboard

The aliases of the command

Link copied to clipboard

The arguments of the command

Link copied to clipboard

The subcommands of the command

Link copied to clipboard
val description: String? = null

The description of the command

Link copied to clipboard

The name of the command

Link copied to clipboard

The options of the command

Link copied to clipboard

The parent command (or null if this is the root command)

Functions

Link copied to clipboard
fun argument(name: String, description: String? = null, required: Boolean = false, defaultValue: String? = null, valueName: String? = null, valueDescription: String? = null, valueValidator: CommanderValueValidator? = null): CommanderCommand

Create a new argument

Link copied to clipboard

Execute the command

Link copied to clipboard

Get an argument by its name

Link copied to clipboard

Get the full usage of the command

Link copied to clipboard

Get an option by its name (or alias)

Link copied to clipboard

Get an option by its short alias

Link copied to clipboard

Get the usage of the command

Link copied to clipboard
fun option(name: String, aliases: Array<String> = arrayOf(), shortAliases: Array<String> = arrayOf(), description: String? = null, required: Boolean = false, hasValue: Boolean = false, defaultValue: String? = null, valueName: String? = null, valueDescription: String? = null, valueValidator: CommanderValueValidator? = null): CommanderCommand

Get an argument by its name

Link copied to clipboard

Parse an array of arguments

Link copied to clipboard
fun subcommand(name: String, aliases: Array<String> = arrayOf(), description: String? = null, action: CommanderCommandAction? = null, init: CommanderCommand.() -> Unit? = null): CommanderCommand

Create a new subcommand