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

ProcessedArgument

class ProcessedArgument : ArgumentDelegate

An Argument delegate implementation that transforms its values .

Constructors

Name Summary
<init> An Argument delegate implementation that transforms its values .ProcessedArgument(name:String, nvalues:Int, required:Boolean, help:String, helpTags:Map<String,String>, completionCandidatesWithDefault:ValueWithDefault<CompletionCandidates>, transformValue:ArgValueTransformer<ValueT>, transformAll:ArgCallsTransformer<AllT, ValueT>, transformValidator:ArgValidator<AllT>)

Properties

Name Summary
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>
help The description of this argument.val help:String
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
parameterHelp Information about this argument for the help output.val parameterHelp: Argument
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.help, 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.help, 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
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
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.fun RawArgument.choice(vararg choices:String, ignoreCase:Boolean= false):ProcessedArgument<String,String>
convert Convert the argument’s values.fun <T :Any> RawArgument.convert(completionCandidates:CompletionCandidates= completionCandidatesWithDefault.default, conversion:ArgValueTransformer<T>):ProcessedArgument<T, T>
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>
double Convert the argument values to a Double``fun RawArgument.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.fun RawArgument.file():ProcessedArgument<File,File>
fun RawArgument.file(mustExist:Boolean= false, canBeFile:Boolean= true, canBeDir:Boolean= true, mustBeWritable:Boolean= false, mustBeReadable:Boolean= false, canBeSymlink:Boolean= true):ProcessedArgument<File,File>``fun RawArgument.~~file~~(exists:Boolean= false, fileOkay:Boolean= true, folderOkay:Boolean= true, writable:Boolean= false, readable:Boolean= false):ProcessedArgument<File,File>
float Convert the argument values to a Float``fun RawArgument.float():ProcessedArgument<Float,Float>
int Convert the argument values to an Int``fun RawArgument.int():ProcessedArgument<Int,Int>
long Convert the argument values to a Long``fun RawArgument.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>
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.fun RawArgument.path(fileSystem: FileSystem = FileSystems.getDefault()):ProcessedArgument<Path, Path>
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>``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>
restrictTo Restrict the argument values to fit into a range.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>
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>
wrapValue fun RawArgument.~~wrapValue~~(wrapper: (String) ->Any): RawArgument
Wrap the argument’s values after a conversion is applied.fun <T1 :Any, T2 :Any>ProcessedArgument<T1, T1>.wrapValue(wrapper: (T1) -> T2):ProcessedArgument<T2, T2>