Class: Belt::CLI::ConsoleCommand

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ ConsoleCommand

Returns a new instance of ConsoleCommand.



13
14
15
16
17
# File 'lib/belt/cli/console_command.rb', line 13

def initialize(args)
  @args = args
  @options = {}
  parse_options
end

Class Method Details

.run(args) ⇒ Object



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

def self.run(args)
  new(args).run
end

Instance Method Details

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/belt/cli/console_command.rb', line 19

def run
  ENV['BUNDLE_GEMFILE'] ||= File.join(Belt.root, 'Gemfile')

  unless File.exist?(ENV['BUNDLE_GEMFILE'])
    abort "Error: No Gemfile found at #{ENV['BUNDLE_GEMFILE']}. Are you in a Belt project?"
  end

  @environment = @args.first || ENV['BELT_ENV'] || 'dev'
  ENV['ENVIRONMENT'] = @environment

  apply_env_config!

  if @options[:run]
    exec_runner(@options[:run])
  else
    exec_console
  end
end