module Comandante::OptParserTypes

Common Types used inside Comandante

Direct including types

Comandante::OptParser

Constants

EMPTY_ARGS = Array(String).new(size: 0, value: "")

Just in case an empty args array is needed

MAX_ARGS = 256

Default maximum number of program argument, you can however set any number in argument configuration range.

Macros

new_option_action

inside yield you can use parser, id, and value

View source

enum Comandante::OptParserTypes::OptionStyle

Available Types for Options

Members

Switch = 0

Option = 1

RepeatingSwitch = 2

RepeatingOption = 3

Methods

#option?

View source

#repeating_option?

View source

#repeating_switch?

View source

#switch?

View source

alias Comandante::OptParserTypes::OptionValue

Alias definition

Array(String) | Bool | Float64 | Int32 | String

alias Comandante::OptParserTypes::OptionsHash

Alias definition

Hash(String, Array(String) | Bool | Float64 | Int32 | String)

abstract class Comandante::OptParserTypes::CommandAction
inherits Reference

A base class for Command Actions

Direct known subclasses

Comandante::OptParserTypes::NullCommandAction

Methods

abstract #run(global_opts : OptionsHash, opts : OptionsHash, args : Array(String)) : Nil

View source

abstract class Comandante::OptParserTypes::OptionAction
inherits Reference

A base class for Option Actions

Direct known subclasses

Comandante::OptParser::ColorOffAction Comandante::OptParser::DebugAction Comandante::OptParser::VersionAction Comandante::OptParserTypes::NullOptionAction

Methods

abstract #run(parser : OptParser, id : String, value : OptionValue) : OptionValue

View source

struct Comandante::OptParserTypes::CommandConfig
inherits Struct

Constructors

.new(name : String, label : String, description : String = "", arguments_string : String = "", arguments_range : Range(Int32, Int32) = 0..MAX_ARGS, action : CommandAction = NullCommandAction.new, options : Array(OptionConfig) = Array(OptionConfig).new, _id : String = "")

View source

Methods

#_id : String

#action : CommandAction

#arguments_range : Range(Int32, Int32)

#arguments_string : String

#clone

View source

#copy_with(name _name = @name, label _label = @label, description _description = @description, arguments_string _arguments_string = @arguments_string, arguments_range _arguments_range = @arguments_range, action _action = @action, options _options = @options, _id __id = @_id)

View source

#description : String

#label : String

#name : String

#options : Array(OptionConfig)

struct Comandante::OptParserTypes::OptionConfig
inherits Struct

Constructors

.new(name : String, label : String, short : String = "", option_type : OptionStyle = OptionStyle::Switch, default : OptionValue = "", argument_string : String = "ARG", simple_action : OptProc = ->(s : OptionValue) doend, action : OptionAction = NullOptionAction.new)

View source

Methods

#action : OptionAction

#argument_string : String

#clone

View source

#copy_with(name _name = @name, label _label = @label, short _short = @short, option_type _option_type = @option_type, default _default = @default, argument_string _argument_string = @argument_string, simple_action _simple_action = @simple_action, action _action = @action)

View source

#default : OptionValue

#label : String

#name : String

#option_type : OptionStyle

#short : String

#simple_action : OptProc