Class: Karafka::Cli::Console

Inherits:
Base
  • Object
show all
Defined in:
lib/karafka/cli/console.rb

Overview

Console Karafka Cli action

Instance Attribute Summary

Attributes inherited from Base

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

aliases, commands, desc, #initialize, load, name, names, option, parse_options

Methods included from Helpers::Colorize

#green, #grey, #red, #yellow

Constructor Details

This class inherits a constructor from Karafka::Cli::Base

Class Method Details

.consoleString

Returns Console executing command for non-Rails setup.

Examples:

Karafka::Cli::Console.command #=> 'KARAFKA_CONSOLE=true bundle exec irb...'

Returns:

  • (String)

    Console executing command for non-Rails setup



16
17
18
# File 'lib/karafka/cli/console.rb', line 16

def console
  "IRBRC='#{Karafka.gem_root}/.console_irbrc' bundle exec irb -r #{Karafka.boot_file}"
end

.rails_consoleString

Note:

In case of Rails, it has its own console, hence we can just defer to it

Returns Console executing command for Rails setup.

Returns:

  • (String)

    Console executing command for Rails setup



22
23
24
# File 'lib/karafka/cli/console.rb', line 22

def rails_console
  'bundle exec rails console'
end

Instance Method Details

#callObject

Start the Karafka console



28
29
30
31
32
33
34
# File 'lib/karafka/cli/console.rb', line 28

def call
  Info.new.call

  command = ::Karafka.rails? ? self.class.rails_console : self.class.console

  exec "KARAFKA_CONSOLE=true #{command}"
end