class Cling::Option

Overview

Represents a command line flag option, supporting boolean and string values. Options are parsed after the main command taking priority over the argument resolution (see Executor#handle).

Defined in:

cling/option.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(long : String, short : Char | Nil = nil, description : String | Nil = nil, required : Bool = false, type : Type = :none, default : Value::Type = nil) #

[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


[View source]
def default : Value::Type #

[View source]
def default=(default : Value::Type) #

[View source]
def description : String | Nil #

[View source]
def description=(description : String | Nil) #

[View source]
def has_default? : Bool #

Returns true if a default value is set.


[View source]
def is?(name : String) : Bool #

Returns true if the name matches the option's long or short flag name.


[View source]
def long : String #

[View source]
def long=(long : String) #

[View source]
def required=(required : Bool) #

[View source]
def required? : Bool #

[View source]
def short : Char | Nil #

[View source]
def short=(short : Char | Nil) #

[View source]
def to_s(io : IO) : Nil #

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>

[View source]
def type : Type #

[View source]
def type=(type : Type) #

[View source]
def value : Value | Nil #

[View source]
def value=(value : Value | Nil) #

[View source]