clikt / com.github.ajalt.clikt.parameters.types

Package com.github.ajalt.clikt.parameters.types

Functions

choice

fun <T : Any> RawArgument.choice(choices: Map<String, T>): ProcessedArgument<T, T>
fun <T : Any> RawArgument.choice(vararg choices: Pair<String, T>): ProcessedArgument<T, T>

Convert the argument based on a fixed set of values.

fun RawArgument.choice(vararg choices: String): ProcessedArgument<String, String>

Restrict the argument to a fixed set of values.

fun <T : Any> RawOption.choice(choices: Map<String, T>, metavar: String = mvar(choices.keys)): NullableOption<T, T>
fun <T : Any> RawOption.choice(vararg choices: Pair<String, T>, metavar: String = mvar(choices.map { it.first })): NullableOption<T, T>

Convert the option based on a fixed set of values.

fun RawOption.choice(vararg choices: String, metavar: String = mvar(choices.asIterable())): NullableOption<String, String>

Restrict the option to a fixed set of values.

double

fun RawArgument.double(): ProcessedArgument<Double, Double>

Convert the argument values to a Double

fun RawOption.double(): NullableOption<Double, Double>

Convert the option values to a Double

file

fun RawArgument.file(exists: Boolean = false, fileOkay: Boolean = true, folderOkay: Boolean = true, writable: Boolean = false, readable: Boolean = false): ProcessedArgument<File, File>

Convert the argument to a File.

fun RawOption.file(exists: Boolean = false, fileOkay: Boolean = true, folderOkay: Boolean = true, writable: Boolean = false, readable: Boolean = false): NullableOption<File, File>

Convert the option to a File.

float

fun RawArgument.float(): ProcessedArgument<Float, Float>

Convert the argument values to a Float

fun RawOption.float(): NullableOption<Float, Float>

Convert the option values to a Float

int

fun RawArgument.int(): ProcessedArgument<Int, Int>

Convert the argument values to an Int

fun RawOption.int(): NullableOption<Int, Int>

Convert the option values to an Int

long

fun RawArgument.long(): ProcessedArgument<Long, Long>

Convert the argument values to a Long

fun RawOption.long(): NullableOption<Long, Long>

Convert the option values to a Long

path

fun RawArgument.path(exists: Boolean = false, fileOkay: Boolean = true, folderOkay: Boolean = true, writable: Boolean = false, readable: Boolean = false, fileSystem: FileSystem = FileSystems.getDefault()): ProcessedArgument<Path, Path>

Convert the argument to a Path.

fun RawOption.path(exists: Boolean = false, fileOkay: Boolean = true, folderOkay: Boolean = true, writable: Boolean = false, readable: Boolean = false, fileSystem: FileSystem = java.nio.file.FileSystems.getDefault()): NullableOption<Path, Path>

Convert the option to a Path.

restrictTo

fun <T> ProcessedArgument<T, T>.restrictTo(min: T? = null, max: T? = null, clamp: Boolean = false): ProcessedArgument<T, T> where T : Number, T : Comparable<T>
fun <T> ProcessedArgument<T, T>.restrictTo(range: ClosedRange<T>, clamp: Boolean = false): ProcessedArgument<T, T> where T : Number, T : Comparable<T>

Restrict the argument values to fit into a range.

fun <T> OptionWithValues<T?, T, T>.restrictTo(min: T? = null, max: T? = null, clamp: Boolean = false): OptionWithValues<T?, T, T> where T : Number, T : Comparable<T>
fun <T> OptionWithValues<T?, T, T>.restrictTo(range: ClosedRange<T>, clamp: Boolean = false): OptionWithValues<T?, T, T> where T : Number, T : Comparable<T>

Restrict the option values to fit into a range.