Sha256: e6cef8adb07a433ab3c9d4d3a5c72b2878f5c440a8432e39cfbfc582a09b1323

Contents?: true

Size: 1.01 KB

Versions: 36

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Karafka
  # Karafka framework Cli
  class Cli < Thor
    # Console Karafka Cli action
    class Console < Base
      desc 'Start the Karafka console (short-cut alias: "c")'
      option aliases: 'c'

      class << self
        # @return [String] Console executing command for non-Rails setup
        # @example
        #   Karafka::Cli::Console.command #=> 'KARAFKA_CONSOLE=true bundle exec irb...'
        def console
          "IRBRC='#{Karafka.gem_root}/.console_irbrc' bundle exec irb -r #{Karafka.boot_file}"
        end

        # @return [String] Console executing command for Rails setup
        # @note In case of Rails, it has its own console, hence we can just defer to it
        def rails_console
          'bundle exec rails console'
        end
      end

      # Start the Karafka console
      def call
        cli.info

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

        exec "KARAFKA_CONSOLE=true #{command}"
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
karafka-2.2.7 lib/karafka/cli/console.rb
karafka-2.2.6 lib/karafka/cli/console.rb
karafka-2.2.5 lib/karafka/cli/console.rb
karafka-2.2.4 lib/karafka/cli/console.rb
karafka-2.2.3 lib/karafka/cli/console.rb
karafka-2.2.2 lib/karafka/cli/console.rb
karafka-2.2.1 lib/karafka/cli/console.rb
karafka-2.2.0 lib/karafka/cli/console.rb
karafka-2.1.13 lib/karafka/cli/console.rb
karafka-2.1.12 lib/karafka/cli/console.rb
karafka-2.1.11 lib/karafka/cli/console.rb
karafka-2.1.10 lib/karafka/cli/console.rb
karafka-2.1.9 lib/karafka/cli/console.rb
karafka-2.1.8 lib/karafka/cli/console.rb
karafka-2.1.7 lib/karafka/cli/console.rb
karafka-2.1.6 lib/karafka/cli/console.rb
karafka-2.1.5 lib/karafka/cli/console.rb
karafka-2.1.5.beta1 lib/karafka/cli/console.rb
karafka-2.1.4 lib/karafka/cli/console.rb
karafka-2.1.3 lib/karafka/cli/console.rb