class Samovar::Nested
def initialize(name, commands, key: :command)
def initialize(name, commands, key: :command) @name = name @commands = commands @key = key end
def parse(input)
def parse(input) if command = @commands[input.first] input.shift # puts "Instantiating #{command} with #{input}" command.new(input) end end
def to_a
def to_a [@name, "One of #{@commands.keys.join(', ')}."] end
def to_s
def to_s @name end
def usage(rows)
def usage(rows) rows << self @commands.each do |key, klass| klass.usage(rows, key) end end