keepcosmos/terjira

View on GitHub
bin/jira

Summary

Maintainability
Test Coverage
#!/usr/bin/env ruby

# Do I need bundler setup?
# require 'bundler/setup'
require 'terjira'
require 'json'
require 'pastel'

begin
  Terjira::CLI.start(ARGV)
  Terjira::VersionChecker.check_version
rescue SystemExit, Interrupt
rescue JIRA::HTTPError => e
  message = JSON.parse(e.response.body)
  pastel = Pastel.new
  if message['errorMessages'].present?
    puts pastel.red(message['errorMessages'].join("\n"))
  elsif message['errors'].present?
    puts pastel.red(message['errors'].map { |k, v| "#{k}: #{v}" }.join(", "))
  end
rescue => e
  puts Pastel.new.dim(e.message)
end