Skip to content

CommandSpec

Describes a command: its name, description, optional version, and parameters.

CommandSpec.kt

Constructors

CommandSpec

CommandSpec(programName: String, description: String, params: List<ParamSpec>, version: String?)
programName

the program name shown in usage.

description

a one-line description shown at the top of --help.

params

the declared parameters, in the order they should appear in --help.

version

when set, --version is recognized and prints this string.

CommandSpec.kt

Properties

description

val description: String
CommandSpec.kt

params

val params: List<ParamSpec>
CommandSpec.kt

programName

val programName: String
CommandSpec.kt

version

val version: String?
CommandSpec.kt

Functions

renderHelp

fun renderHelp(): String

Renders the full --help text: description, usage line, then aligned options and arguments.

CommandSpec.kt

renderUsage

fun renderUsage(): String

Renders the single-line usage string, for example Usage: serve [options] <files>....

CommandSpec.kt

validate

fun validate(): Unit

Checks this specification for problems such as duplicate names, blank names, or a misplaced multiple positional.

ThrowsIllegalArgumentException

if the specification is malformed.

CommandSpec.kt

Released under the Apache License 2.0.