Class: Karafka::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/karafka/cli.rb,
lib/karafka/cli/base.rb,
lib/karafka/cli/help.rb,
lib/karafka/cli/info.rb,
lib/karafka/cli/swarm.rb,
lib/karafka/cli/server.rb,
lib/karafka/cli/topics.rb,
lib/karafka/cli/console.rb,
lib/karafka/cli/install.rb,
lib/karafka/cli/topics/base.rb,
lib/karafka/cli/topics/plan.rb,
lib/karafka/cli/topics/align.rb,
lib/karafka/cli/topics/reset.rb,
lib/karafka/cli/topics/create.rb,
lib/karafka/cli/topics/delete.rb,
lib/karafka/cli/topics/migrate.rb,
lib/karafka/cli/topics/repartition.rb

Overview

Karafka framework Cli

Defined Under Namespace

Classes: Base, Console, Help, Info, Install, Server, Swarm, Topics

Class Method Summary collapse

Class Method Details

.startObject

Starts the CLI



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/karafka/cli.rb', line 11

def start
  # Command we want to run, like install, server, etc
  command_name = ARGV[0]
  # Action for action-based commands like topics migrate
  action = ARGV[1].to_s.start_with?('-') ? false : ARGV[1]

  command = commands.find { |cmd| cmd.names.include?(command_name) }

  if command
    # Only actionable commands require command as an argument
    args = action ? [action] : []

    command.new.call(*args)
  else
    raise(
      Karafka::Errors::UnrecognizedCommandError,
      "Unrecognized command \"#{command_name}\""
    )
  end
end