abstract class Optimist::Option

Overview

Abstract base class for all other Options.

Direct Known Subclasses

Defined in:

optimist/option.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(name : String, desc : String, default : T, long : LongNameType = nil, alt : AlternatesType = nil, short : ShortNameType = nil, permitted : PermittedType = nil, callback : Option -> Nil | Nil = nil, permitted_response : String = "option '%{arg}' only accepts %{valid_string}", required : Bool = false, hidden : Bool = false, multi : Bool | Nil = nil) forall T #

[View source]

Class Method Detail

def self.create(name : String, desc : String, cls : Class | Nil = nil, default : _ = nil, **kwargs) #

Factory class method Determines which type of object to create based on arguments passed to Optimist.opt. This is tricky because we allow the default to be able to set the option's type.


[View source]

Instance Method Detail

abstract def add_argument_value(a : Array(String), b : Bool) #

[View source]
abstract def default #

[View source]
def desc : String #

[View source]
def description_with_default(str) #

Format the educate-line description including the default-value(s)


[View source]
def description_with_permitted(str) #

Format the educate-line description including the permitted-value(s)


[View source]
def disallow_multiple_args(paramlist : Array(String)) #

[View source]
def doesnt_need_autogen_short #

TODO push into SHORT


[View source]
def educate #

[View source]
def format_stdio(obj) #

Format stdio like objects to a string


[View source]
def full_description #

Format the educate-line description including the default and permitted value(s)


[View source]
def given? : Bool #

[View source]
def long : Optimist::LongNames #

[View source]
def max_args : Int32 #

[View source]
def min_args : Int32 #

[View source]
def name : String #

[View source]
def needs_an_argument #

[View source]
def permitted : Array(Int32) | Array(String) | Range(Int32, Int32) | Regex | Nil #

[View source]
def permitted_response : String #

[View source]
def permitted_type_valid? #

[View source]
def permitted_value?(val : DefaultType) : Bool #

Incoming values from the command-line should be strings, so we should stringify any permitted types as the basis of comparison.


[View source]
def required? : Bool #

[View source]
def short : Optimist::ShortNames #

[View source]
def takes_an_argument #

[View source]
def takes_multiple #

[View source]
def trigger_callback #

[View source]
def type_format #

Provide type-format string. Default to empty, but should probably be overridden for most subclasses.


[View source]
def validate_permitted(arg : String, value : DefaultType) : Void #

[View source]
abstract def value #

[View source]