abstract class Optarg::Model
- Optarg::Model
- Reference
- Object
Overview
The base of model classes.
Defined in:
lib/model.crlib/model/dsl/arg.cr
lib/model/dsl/arg_array.cr
lib/model/dsl/array.cr
lib/model/dsl/bool.cr
lib/model/dsl/handler.cr
lib/model/dsl/string.cr
lib/model/dsl/terminator.cr
lib/model/dsl/unknown.cr
lib/model/macros/handler.cr
lib/model/macros/value.cr
Class Method Summary
-
.parse(argv : Array(String), *args)
Creates a new model instance and parses the argv arguments.
Macro Summary
-
arg(names, metadata = nil, stop = nil, default = nil, required = nil, any_of = nil, complete = nil, _mixin = nil, &block)
Defines a String argument model item.
-
arg_array(names, metadata = nil, default = nil, min = nil, any_item_of = nil, complete = nil, _mixin = nil, &block)
Defines an Array(String) argument model item.
-
array(names, metadata = nil, default = nil, min = nil, any_item_of = nil, complete = nil, _mixin = nil, &block)
Defines an Array(String) option model item.
-
bool(names, metadata = nil, stop = nil, default = nil, not = nil, _mixin = nil, &block)
Defines a Bool option model item.
-
on(names, metadata = nil, stop = nil, &block)
Defines a handler model item.
-
string(names, metadata = nil, stop = nil, default = nil, required = nil, any_of = nil, complete = nil, _mixin = nil, &block)
Defines a String option model item.
-
terminator(names, metadata = nil)
Defines a terminator model item.
-
unknown(metadata = nil)
Defines an unknown model item.
Instance Method Summary
-
#[](klass : String.class)
Returns a value hash for String-type options and arguments.
-
#[](klass : Bool.class)
Returns a value hash for Bool-type options and arguments.
-
#[](klass : Array(String).class)
Returns a value hash for Array(String)-type options and arguments.
-
#[](index : Int32)
Returns an argument value at the index.
-
#[]?(index : Int32)
Returns an argument value at the index.
-
#each(&)
Iterates argument values.
-
#nameless_args
Returns an array that contains nameless argument values.
-
#unparsed_args
Returns an array that contains unparsed argument values.
Class Method Detail
Creates a new model instance and parses the argv arguments.
Returns the created instance.
Macro Detail
Defines a String argument model item.
Defines an Array(String) argument model item.
Defines an Array(String) option model item.
Defines a Bool option model item.
Defines a String option model item.
Instance Method Detail
Returns a value hash for String-type options and arguments.
Returns a value hash for Bool-type options and arguments.
Returns a value hash for Array(String)-type options and arguments.
Returns an argument value at the index.
Returns nil if the index is out of range.