class CLASP::FlagAlias

A class that represents the specification for a command-line flag

Attributes

action[R]

(Proc) The procedure

aliases[R]

The flag's aliases array

extras[R]

The flag's extras

help[R]

The flag's help string

name[R]

The flag's name string

Public Class Methods

Help(extras = nil, &blk) click to toggle source

An instance of FlagSpecification that provides default '–help' information

If you wish to specify extras or attach a block, you may do so

# File lib/clasp/specifications.rb, line 188
def self.Help(extras = nil, &blk)

        h = @@Help_

        if extras || blk

                return self.new(h.name, h.aliases, h.help, extras, &blk)
        end

        h
end
Version(extras = nil, &blk) click to toggle source

An instance of FlagSpecification that provides default '–version' information

If you wish to specify extras or attach a block, you may do so

# File lib/clasp/specifications.rb, line 203
def self.Version(extras = nil, &blk)

        h = @@Version_

        if extras || blk

                return self.new(h.name, h.aliases, h.help, extras, &blk)
        end

        h
end
new(name, aliases, help, extras = nil, &blk) click to toggle source

Creates a FlagSpecification instance from the given name, aliases, and help

Signature

  • Parameters

    • name (String) The name, or long-form, of the flag

    • aliases (Array) 0 or more strings specifying short-form or option-value aliases

    • help (String) The help string, which may be nil

    • extras An application-defined additional parameter. If nil, it is assigned an empty Hash

  • Block An optional block that is called when a matching flag argument is found

NOTE: Users should prefer the +CLASP::Flag()+ method

# File lib/clasp/specifications.rb, line 108
def initialize(name, aliases, help, extras = nil, &blk)

        check_arity_(blk, 0..3, "flag")

        @name                 =     name
        @aliases              =   (aliases || []).select { |a| a and not a.empty? }
        @help                 =     help
        @extras                       =   extras || {}
        @action                       =   blk
end

Public Instance Methods

==(rhs) click to toggle source

Compares instance against another FlagSpecification or against a name (String)

# File lib/clasp/specifications.rb, line 166
def == rhs

        case rhs
        when self.class

                return self.eql? rhs
        when String

                return name == rhs
        else

                false
        end
end
to_s() click to toggle source

String form of the flag

# File lib/clasp/specifications.rb, line 140
def to_s

        "{#{name}; aliases=#{aliases.join(', ')}; help='#{help}'; extras=#{extras}}"
end