class CLI::Kit::BaseCommand

Public Class Methods

call(args, command_name) click to toggle source
# File lib/cli/kit/base_command.rb, line 18
def self.call(args, command_name)
  cmd = new
  stats_tags = cmd.stats_tags(args, command_name)
  begin
    statsd_increment("cli.command.invoked", tags: stats_tags)
    statsd_time("cli.command.time", tags: stats_tags) do
      cmd.call(args, command_name)
    end
    statsd_increment("cli.command.success", tags: stats_tags)
  rescue Exception => e # rubocop:disable Lint/RescueException
    statsd_increment("cli.command.exception", tags: stats_tags + ["exception:#{e.class}"])
    raise e
  end
end
defined?() click to toggle source
# File lib/cli/kit/base_command.rb, line 6
def self.defined?
  true
end
statsd_increment(_metric, **_kwargs) click to toggle source
# File lib/cli/kit/base_command.rb, line 10
def self.statsd_increment(_metric, **_kwargs)
  nil
end
statsd_time(_metric, **_kwargs) { || ... } click to toggle source
# File lib/cli/kit/base_command.rb, line 14
def self.statsd_time(_metric, **_kwargs)
  yield
end

Public Instance Methods

call(_args, _command_name) click to toggle source
# File lib/cli/kit/base_command.rb, line 40
def call(_args, _command_name)
  raise NotImplementedError
end
has_subcommands?() click to toggle source
# File lib/cli/kit/base_command.rb, line 44
def has_subcommands?
  false
end
stats_tags(args, command_name) click to toggle source
# File lib/cli/kit/base_command.rb, line 33
def stats_tags(args, command_name)
  tags = ["task:#{self.class}"]
  tags << "command:#{command_name}" if command_name
  tags << "subcommand:#{args.first}" if args&.first && has_subcommands?
  tags
end