class WB::CLI

Attributes

commands[R]

Public Class Methods

new(commands) click to toggle source
# File lib/wb/cli.rb, line 3
def initialize(commands)
  @commands = commands
end

Public Instance Methods

run(arguments: ARGV) click to toggle source
# File lib/wb/cli.rb, line 7
def run(arguments: ARGV)
  command = find_command(arguments[0])
  command.run(arguments[1])
end

Private Instance Methods

default_command() click to toggle source
# File lib/wb/cli.rb, line 25
def default_command
  commands.find { |command| command.name == "" }
end
find_command(name) click to toggle source
# File lib/wb/cli.rb, line 16
def find_command(name)
  command = find_command_by_name(name) || default_command
  command.new
end
find_command_by_name(name) click to toggle source
# File lib/wb/cli.rb, line 21
def find_command_by_name(name)
  commands.find { |command| command.name == name }
end