class Opal::CLI::Context

Overview

Context passed into command run blocks containing resolved arguments and flags.

Defined in:

opal/cli/context.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(flags : Hash(Symbol, Bool) = Hash(Symbol, Bool).new, options : Hash(Symbol, Array(String) | Bool | Float64 | Int32 | String | Nil) = Hash(Symbol, OptionValue).new, args : Array(String) = Array(String).new, named_args : Hash(Symbol, String) = Hash(Symbol, String).new, raw_args : Array(String) = Array(String).new) #

[View source]

Instance Method Detail

def [](name : Symbol) : OptionValue #

Retrieves an option by name


[View source]
def []?(name : Symbol) : OptionValue #

[View source]
def arg(name : Symbol) : String | Nil #

Retrieves a positional argument by name


[View source]
def arg!(name : Symbol) : String #

[View source]
def args : Array(String) #

[View source]
def array(name : Symbol) : Array(String) #

Strongly-typed array getter


[View source]
def flag?(name : Symbol) : Bool #

Returns true if flag was specified


[View source]
def flags : Hash(Symbol, Bool) #

[View source]
def float(name : Symbol) : Float64 #

[View source]
def float?(name : Symbol) : Float64 | Nil #

Strongly-typed float getter


[View source]
def int(name : Symbol) : Int32 #

[View source]
def int?(name : Symbol) : Int32 | Nil #

Strongly-typed int getter


[View source]
def named_args : Hash(Symbol, String) #

[View source]
def options : Hash(Symbol, OptionValue) #

[View source]
def raw_args : Array(String) #

[View source]
def string(name : Symbol) : String #

[View source]
def string?(name : Symbol) : String | Nil #

Strongly-typed string getter


[View source]