ProcessedArgument

An Argument delegate implementation that transforms its values .

Inheritors

Properties

Link copied to clipboard

Optional set of strings to use when the user invokes shell autocomplete on a value for this argument.

Link copied to clipboard

The completion candidates set on this argument, or null if no candidates have been set

Link copied to clipboard

A block that will return the help text for this argument, or null if no getter has been specified

Link copied to clipboard
abstract val helpTags: Map<String, String>

Extra information about this argument to pass to the help formatter.

Link copied to clipboard
abstract val name: String

The metavar for this argument.

Link copied to clipboard
abstract val nvalues: Int

The number of values that this argument takes.

Link copied to clipboard
abstract val required: Boolean

If true, an error will be thrown if this argument is not given on the command line.

Link copied to clipboard

Called in finalize to transform the list of values to the final type.

Link copied to clipboard

Called after all parameters have been finalized to validate the result of transformAll

Link copied to clipboard

Called in finalize to transform each value provided to the argument.

Link copied to clipboard
abstract val value: AllT

The value for this argument.

Functions

Link copied to clipboard

Convert the argument values to Boolean.

Link copied to clipboard
inline fun <AllT, ValueT> ProcessedArgument<AllT, ValueT>.check(crossinline lazyMessage: (AllT & Any) -> String = { it.toString() }, crossinline validator: (AllT & Any) -> Boolean): ArgumentDelegate<AllT>
inline fun <AllT, ValueT> ProcessedArgument<AllT, ValueT>.check(message: String, crossinline validator: (AllT & Any) -> Boolean): ArgumentDelegate<AllT>

Check the final argument value and raise an error if it's not valid.

Link copied to clipboard
fun <T : Any> RawArgument.choice(vararg choices: Pair<String, T>, ignoreCase: Boolean = false): ProcessedArgument<T, T>
fun <T : Any> RawArgument.choice(choices: Map<String, T>, ignoreCase: Boolean = false): ProcessedArgument<T, T>

Convert the argument based on a fixed set of values.

fun RawArgument.choice(vararg choices: String, ignoreCase: Boolean = false): ProcessedArgument<String, String>

Restrict the argument to a fixed set of values.

Link copied to clipboard
inline fun <InT : Any, ValueT : Any> ProcessedArgument<InT, InT>.convert(completionCandidates: CompletionCandidates? = explicitCompletionCandidates, crossinline conversion: ArgValueConverter<InT, ValueT>): ProcessedArgument<ValueT, ValueT>

Convert the argument's values.

Link copied to clipboard
abstract fun copy(validator: ArgValidator<AllT> = this.transformValidator, name: String = this.name, nvalues: Int = this.nvalues, required: Boolean = this.required, helpGetter: HelpTransformContext.() -> String? = this.helpGetter, helpTags: Map<String, String> = this.helpTags, completionCandidates: CompletionCandidates? = explicitCompletionCandidates): ProcessedArgument<AllT, ValueT>

Create a new argument that is a copy of this one with the same transforms.

abstract fun <AllT, ValueT> copy(transformValue: ArgValueTransformer<ValueT>, transformAll: ArgCallsTransformer<AllT, ValueT>, validator: ArgValidator<AllT>, name: String = this.name, nvalues: Int = this.nvalues, required: Boolean = this.required, helpGetter: HelpTransformContext.() -> String? = this.helpGetter, helpTags: Map<String, String> = this.helpTags, completionCandidates: CompletionCandidates? = explicitCompletionCandidates): ProcessedArgument<AllT, ValueT>

Create a new argument that is a copy of this one with different transforms.

Link copied to clipboard
fun <T : Any> ProcessedArgument<T, T>.default(value: T, defaultForHelp: String = value.toString()): ArgumentDelegate<T>

If the argument is not given, use value instead of throwing an error.

Link copied to clipboard
inline fun <T : Any> ProcessedArgument<T, T>.defaultLazy(defaultForHelp: String = "", crossinline value: () -> T): ArgumentDelegate<T>

If the argument is not given, call value and use its return value instead of throwing an error.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Convert the argument values to a Double

Link copied to clipboard
inline fun <T : Enum<T>> RawArgument.enum(ignoreCase: Boolean = true, key: (T) -> String = { it.name }): ProcessedArgument<T, T>

Convert the argument to the values of an enum.

Link copied to clipboard
fun RawArgument.file(mustExist: Boolean = false, canBeFile: Boolean = true, canBeDir: Boolean = true, mustBeWritable: Boolean = false, mustBeReadable: Boolean = false, canBeSymlink: Boolean = true): ProcessedArgument<File, File>

Convert the argument to a File.

Link copied to clipboard
abstract fun finalize(context: Context, values: List<String>)

Called after this command's argv is parsed to transform and store the argument's value.

Link copied to clipboard

Convert the argument values to a Float

Link copied to clipboard
abstract fun getArgumentHelp(context: Context): String

The description of this argument.

Link copied to clipboard
open operator override fun getValue(thisRef: CliktCommand, property: KProperty<*>): AllT
Link copied to clipboard

Set the help for this argument lazily.

Set the help for this argument.

Link copied to clipboard
fun RawArgument.inputStream(fileSystem: FileSystem = FileSystems.getDefault()): ProcessedArgument<InputStream, InputStream>

Convert the argument to an InputStream.

Link copied to clipboard

Convert the argument values to an Int

Link copied to clipboard

Convert the argument values to a Long

Link copied to clipboard
fun <T : Any> ProcessedArgument<T, T>.multiple(required: Boolean = false, default: List<T> = emptyList()): ProcessedArgument<List<T>, T>

Accept any number of values to this argument.

Link copied to clipboard

Return null instead of throwing an error if no value is given.

Link copied to clipboard
fun RawArgument.outputStream(createIfNotExist: Boolean = true, truncateExisting: Boolean = false, fileSystem: FileSystem = FileSystems.getDefault()): ProcessedArgument<OutputStream, OutputStream>

Convert the argument to an OutputStream.

Link copied to clipboard

Require exactly two values to this argument, and store them in a Pair.

Link copied to clipboard

Information about this argument for the help output.

Link copied to clipboard
fun RawArgument.path(mustExist: Boolean = false, canBeFile: Boolean = true, canBeDir: Boolean = true, mustBeWritable: Boolean = false, mustBeReadable: Boolean = false, canBeSymlink: Boolean = true, fileSystem: FileSystem = FileSystems.getDefault()): ProcessedArgument<Path, Path>

Convert the argument to a Path.

Link copied to clipboard
abstract fun postValidate(context: Context)

Called after all of a command's parameters have been finalized to perform validation of the final value.

Link copied to clipboard
abstract operator fun provideDelegate(thisRef: CliktCommand, property: KProperty<*>): ReadOnlyProperty<CliktCommand, AllT>
Link copied to clipboard
fun <T : Comparable<T>> ProcessedArgument<T, T>.restrictTo(min: T? = null, max: T? = null, clamp: Boolean = false): ProcessedArgument<T, T>

Restrict the argument values to fit into a range.

Link copied to clipboard
fun <AllInT, ValueT, AllOutT> ProcessedArgument<AllInT, ValueT>.transformAll(nvalues: Int? = null, required: Boolean? = null, defaultForHelp: String? = null, transform: ArgCallsTransformer<AllOutT, ValueT>): ProcessedArgument<AllOutT, ValueT>

Transform all values to the final argument type.

Link copied to clipboard

Require exactly three values to this argument, and store them in a Triple

Link copied to clipboard

Convert the argument values to an UInt

Link copied to clipboard

Convert the argument values to a ULong

Link copied to clipboard

Only store unique values for this argument

Link copied to clipboard

Check the final argument value and raise an error if it's not valid.