Class: Ecogem::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/ecogem/cli.rb,
lib/ecogem/cli/args.rb,
lib/ecogem/cli/commands/install.rb

Defined Under Namespace

Modules: Commands Classes: Args

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Cli

Returns a new instance of Cli.



9
10
11
# File 'lib/ecogem/cli.rb', line 9

def initialize(argv)
  @args = ::Ecogem::Cli::Args.new(argv)
end

Class Method Details

.start(argv) ⇒ Object



5
6
7
# File 'lib/ecogem/cli.rb', line 5

def self.start(argv)
  self.new(argv).execute
end

Instance Method Details

#executeObject



13
14
15
16
17
18
19
# File 'lib/ecogem/cli.rb', line 13

def execute
  raise "Unknown command: #{@args.command}" unless %w[install update].include?(@args.command)
  require_relative "cli/commands/#{@args.command}"
  klass_name = @args.command.split(/_/).map{|i| i[0].upcase + i[1..-1]}.join('')
  klass = ::Ecogem::Cli::Commands.const_get(klass_name, false)
  klass.new(@args).execute
end