class RuboCop::Daemon::ClientCommand::Exec

Public Instance Methods

run() click to toggle source
# File lib/rubocop/daemon/client_command/exec.rb, line 7
def run
  args = parser.parse(@argv)
  ensure_server!
  Cache.status_path.delete if Cache.status_path.file?
  send_request(
    command: 'exec',
    args: args,
    body: $stdin.tty? ? '' : $stdin.read,
  )
  exit_with_status!
end

Private Instance Methods

exit_with_status!() click to toggle source
# File lib/rubocop/daemon/client_command/exec.rb, line 27
def exit_with_status!
  raise "rubocop-daemon: Could not find status file at: #{Cache.status_path}" unless Cache.status_path.file?

  status = Cache.status_path.read
  raise "rubocop-daemon: '#{status}' is not a valid status!" if (status =~ /^\d+$/).nil?

  exit status.to_i
end
parser() click to toggle source
# File lib/rubocop/daemon/client_command/exec.rb, line 21
def parser
  @parser ||= CLI.new_parser do |p|
    p.banner = 'usage: rubocop-daemon exec [options] [files...] [-- [rubocop-options]]'
  end
end