class Cling::Argument

Overview

Represents a command line argument, this can be a single value or a string value. Arguments are parsed after the main command and any subcommands are resolved. Note that Options that have values take priority in the resolution list, so the following example would only yield 2 arguments:

./greet --time=day Dev
#              ^^^
# belongs to the flag option

Arguments should typically be defined in the Command#setup method of a command using Command#add_argument to prevent conflicts.

Defined in:

cling/argument.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(name : String, description : String | Nil = nil, required : Bool = false, multiple : Bool = false) #

[View source]

Instance Method Detail

def description : String | Nil #

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

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

[View source]
def multiple? : Bool #

[View source]
def name : String #

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

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

[View source]
def required? : Bool #

[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 value : Value | Nil #

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

[View source]