Skip to content

clikt / com.github.ajalt.clikt.parameters.arguments / ProcessedArgument

ProcessedArgument

class ProcessedArgument : ArgumentDelegate

An Argument delegate implementation that transforms its values .

Properties

Name Summary
argumentHelp The description of this argument.val argumentHelp:String
completionCandidates Optional set of strings to use when the user invokes shell autocomplete on a value for this argument.val completionCandidates:CompletionCandidates
completionCandidatesWithDefault val completionCandidatesWithDefault:ValueWithDefault<CompletionCandidates>
helpTags Extra information about this argument to pass to the help formatter.val helpTags:Map<String,String>
name The metavar for this argument.var name:String
nvalues The number of values that this argument takes.val nvalues:Int
required If true, an error will be thrown if this argument is not given on the command line.val required:Boolean
transformAll Called in finalize to transform the list of values to the final type.val transformAll:ArgCallsTransformer<AllT, ValueT>
transformValidator Called after all parameters have been finalized to validate the result of transformAllval transformValidator:ArgValidator<AllT>
transformValue Called in finalize to transform each value provided to the argument.val transformValue:ArgValueTransformer<ValueT>

Functions

Name Summary
copy Create a new argument that is a copy of this one with different transforms.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, help:String= this.argumentHelp, helpTags:Map<String,String> = this.helpTags, completionCandidatesWithDefault:ValueWithDefault<CompletionCandidates> = this.completionCandidatesWithDefault):ProcessedArgument<AllT, ValueT>
Create a new argument that is a copy of this one with the same transforms.fun copy(validator:ArgValidator<AllT> = this.transformValidator, name:String= this.name, nvalues:Int= this.nvalues, required:Boolean= this.required, help:String= this.argumentHelp, helpTags:Map<String,String> = this.helpTags, completionCandidatesWithDefault:ValueWithDefault<CompletionCandidates> = this.completionCandidatesWithDefault):ProcessedArgument<AllT, ValueT>
finalize Called after this command’s argv is parsed to transform and store the argument’s value.fun finalize(context:Context, values:List<String>):Unit
getValue fun getValue(thisRef:CliktCommand, property:KProperty<*>): AllT
parameterHelp Information about this argument for the help output.fun parameterHelp(context:Context): Argument
postValidate Called after all of a command’s parameters have been finalized to perform validation of the final value.fun postValidate(context:Context):Unit
provideDelegate Implementations must call CliktCommand.registerArgumentoperator fun provideDelegate(thisRef:CliktCommand, prop:KProperty<*>):ReadOnlyProperty<CliktCommand, AllT>

Extension Functions

Name Summary
check Check the final argument value and raise an error if it’s not valid.fun <AllT :Any, ValueT>ProcessedArgument<AllT, ValueT>.check(message:String, validator: (AllT) ->Boolean):ArgumentDelegate<AllT>
fun <AllT :Any, ValueT>ProcessedArgument<AllT, ValueT>.check(lazyMessage: (AllT) ->String= { it.toString() }, validator: (AllT) ->Boolean):ArgumentDelegate<AllT>
choice Convert the argument based on a fixed set of values.fun <T :Any>RawArgument.choice(choices:Map<String, T>, ignoreCase:Boolean= false):ProcessedArgument<T, T>
fun <T :Any>RawArgument.choice(vararg choices:Pair<String, T>, ignoreCase:Boolean= false):ProcessedArgument<T, T>
Restrict the argument to a fixed set of values.funRawArgument.choice(vararg choices:String, ignoreCase:Boolean= false):ProcessedArgument<String,String>
convert Convert the argument’s values.fun <InT :Any, ValueT :Any>ProcessedArgument<InT, InT>.convert(completionCandidates:CompletionCandidates= completionCandidatesWithDefault.default, conversion:ArgValueConverter<InT, ValueT>):ProcessedArgument<ValueT, ValueT>
default If the argument is not given, use value instead of throwing an error.fun <T :Any>ProcessedArgument<T, T>.default(value: T):ArgumentDelegate<T>
defaultLazy If the argument is not given, call value and use its return value instead of throwing an error.fun <T :Any>ProcessedArgument<T, T>.defaultLazy(value: () -> T):ArgumentDelegate<T>
defaultStdin Use - as the default value for an inputStream argument.funProcessedArgument<InputStream,InputStream>.defaultStdin():ArgumentDelegate<InputStream>
defaultStdout Use - as the default value for an outputStream argument.funProcessedArgument<OutputStream,OutputStream>.defaultStdout():ArgumentDelegate<OutputStream>
double Convert the argument values to a Double``funRawArgument.double():ProcessedArgument<Double,Double>
enum Convert the argument to the values of an enum.fun <T :Enum<T>>RawArgument.enum(ignoreCase:Boolean= true, key: (T) ->String= { it.name }):ProcessedArgument<T, T>
file Convert the argument to a File.funRawArgument.file(mustExist:Boolean= false, canBeFile:Boolean= true, canBeDir:Boolean= true, mustBeWritable:Boolean= false, mustBeReadable:Boolean= false, canBeSymlink:Boolean= true):ProcessedArgument<File,File>
float Convert the argument values to a Float``funRawArgument.float():ProcessedArgument<Float,Float>
help Set the help for this argument.fun <AllT, ValueT>ProcessedArgument<AllT, ValueT>.help(help:String):ProcessedArgument<AllT, ValueT>
inputStream Convert the argument to an InputStream.funRawArgument.inputStream(fileSystem: FileSystem = FileSystems.getDefault()):ProcessedArgument<InputStream,InputStream>
int Convert the argument values to an Int``funRawArgument.int():ProcessedArgument<Int,Int>
long Convert the argument values to a Long``funRawArgument.long():ProcessedArgument<Long,Long>
multiple Accept any number of values to this argument.fun <T :Any>ProcessedArgument<T, T>.multiple(required:Boolean= false):ProcessedArgument<List<T>, T>
optional Return null instead of throwing an error if no value is given.fun <AllT :Any, ValueT>ProcessedArgument<AllT, ValueT>.optional():ProcessedArgument<AllT?, ValueT>
outputStream Convert the argument to an OutputStream.funRawArgument.outputStream(createIfNotExist:Boolean= true, truncateExisting:Boolean= false, fileSystem: FileSystem = FileSystems.getDefault()):ProcessedArgument<OutputStream,OutputStream>
pair Require exactly two values to this argument, and store them in a Pair.fun <T :Any>ProcessedArgument<T, T>.pair():ProcessedArgument<Pair<T, T>, T>
path Convert the argument to a Path.funRawArgument.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>
restrictTo Restrict the argument values to fit into a range.fun <T :Comparable<T>>ProcessedArgument<T, T>.restrictTo(min: T? = null, max: T? = null, clamp:Boolean= false):ProcessedArgument<T, T>
fun <T :Comparable<T>>ProcessedArgument<T, T>.restrictTo(range:ClosedRange<T>, clamp:Boolean= false):ProcessedArgument<T, T>
transformAll Transform all values to the final argument type.fun <AllInT, ValueT, AllOutT>ProcessedArgument<AllInT, ValueT>.transformAll(nvalues:Int? = null, required:Boolean? = null, transform:ArgCallsTransformer<AllOutT, ValueT>):ProcessedArgument<AllOutT, ValueT>
triple Require exactly three values to this argument, and store them in a Triplefun <T :Any>ProcessedArgument<T, T>.triple():ProcessedArgument<Triple<T, T, T>, T>
unique Only store unique values for this argumentfun <T :Any>ProcessedArgument<List<T>, T>.unique():ProcessedArgument<Set<T>, T>
validate Check the final argument value and raise an error if it’s not valid.fun <AllT :Any, ValueT>ProcessedArgument<AllT, ValueT>.validate(validator:ArgValidator<AllT>):ArgumentDelegate<AllT>