Class: Binder::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/cli/command.rb

Overview

Public: A Class to create Command Line Tool commands.

Examples

Binder::Command.new ARGV
# => Will execute any command passed in ARGV
# A command is just a ruby Class, subclassing the Binder::Strategy Class.
#
# When you do :
Binder::Command.new "migrate --version 1.1"
# => The Binder::Migrate class is instanciated and it's execute method is called.

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Command

Returns a new instance of Command.



17
18
19
20
21
22
23
24
25
# File 'lib/cli/command.rb', line 17

def initialize args
  raise CommandParser::ParseError.new("No command specified.") if args.empty?

  # ['--migrate' 'param'] => 'migrate'
  command  = args.shift.gsub(/\-/, '')

  strategy = Binder::const_get(command.capitalize).new
  puts strategy.execute args
end