| argumentsCode | = | nil |
- <=>(other)
- arity()
- coercing(+types, +:coersions)
- consume(argv, handler iopt iopt:ion(argv first), untilNextOption: true, coerce: nil)
- initialize()
- perform(args, iopt nil)
- priority=(value)
- receiver()
nil
[ show source ]
method(+types, +:coersions, @ coerce = IOpt CommandLine Coerce mimic(*(types), *(coersions)) self)
Take arguments for this action according to its arity. The argv list must have its first element be one of the options handled by this action otherwise a NoActionForOption will be signaled. This method returns an object with the following cells: option: The option that was processed remnant: The elements from argv that were not taken as arguments for this action. positional: A list of positional arguments for this action. keywords: A dict of keyword arguments for this action.
[ show source ]
method(argv, handler iopt iopt:ion(argv first), untilNextOption: true, coerce: nil,
if(handler nil? ||(!(options include?(handler option))),
error!(NoActionForOption,
text: "Cannot handle option %s not in %s" format(
if(handler, handler option, argv first), options inspect),
option: if(handler, handler option, argv first)))
remnant = argv rest
currentKey = nil
args = list
klist = list
kmap = dict
arity = @ arity
coerced = fn(txt,
if(coerce ==(false) ||(@ coerce ==(false)), txt,
(coerce ||(@ coerce) ||(IOpt CommandLine Coerce mimic)) coerce(txt)))
shouldContinue = fn(arg,
cond(
untilNextOption &&(iopt [](arg)), false,
currentKey, true,
arity rest ||(arity krest), true,
iopt iopt:key(arg),
klist length <(arity keywords length),
args length <(arity positionals length)
)
)
if(handler short &&(handler immediate) &&(arity max abs zero?),
opt = iopt iopt:get(handler short +(handler immediate))
if(opt &&(opt action) &&(opt short),
remnant = [](handler short +(handler immediate)) +(remnant)
handler immediate = nil))
if(handler immediate &&(arity max abs >(0)),
args <<(coerced(handler immediate)))
idx = remnant findIndex(arg,
cond(
!(shouldContinue(arg)), true,
(key = iopt iopt:key(arg)) &&(
(arity krest ||(arity keywords include?(:(key name))))),
keyword = :(key name)
if(kmap key?(keyword),
error!(OptionKeywordAlreadyProvided,
text: "Keyword #{keyword} was specified more than once.",
keyword: keyword),
kmap [](keyword) = coerced(key immediate)
if(key immediate, klist <<(keyword), currentKey = keyword))
false,
currentKey,
klist <<(currentKey)
kmap [](currentKey) = coerced(arg)
currentKey = nil,
args <<(coerced(arg))
false))
Origin with(
option: handler option,
remnant: remnant []((idx ||(0 -(1))) ..(-(1))),
positional: args,
keywords: kmap)
)
nil
[ show source ]
method(args, iopt nil,
messageName = args option
let(@ cell(messageName), @ cell(:call),
@ iopt, if(@ cell?(:iopt), iopt ||(@ iopt), iopt),
send(messageName, *(args positional), *(args keywords))))
Set the option priority. Default priority level is 0. Negative values are higher priority for options that must be processed before those having priority(0). Positive ones are executed just after all priority(0)
[ show source ]
method(value, @ cell(:priority) = value self)