class DocoptCompgen::Node

Attributes

arguments[R]
parent[R]
subcommands[R]

Public Class Methods

new(parent = nil) click to toggle source
# File lib/docopt_compgen/node.rb, line 7
def initialize(parent = nil)
    @parent = parent
    @subcommands = {}
    @options = []
    @arguments = []
end

Public Instance Methods

add_argument(argument) click to toggle source
# File lib/docopt_compgen/node.rb, line 14
def add_argument(argument)
    @arguments << argument
end
add_option(option) click to toggle source
# File lib/docopt_compgen/node.rb, line 18
def add_option(option)
    @options << option
end
add_subcommand(name) click to toggle source
# File lib/docopt_compgen/node.rb, line 30
def add_subcommand(name)
    if @subcommands[name].nil?
        @subcommands[name] = Node.new(self)
    end
    @subcommands[name]
end
options() click to toggle source
# File lib/docopt_compgen/node.rb, line 22
def options
    options = @options
    if @parent
        options += @parent.options
    end
    options.uniq
end