#! /usr/bin/env ruby # Trap interrupts to quit cleanly. See # https://twitter.com/mitchellh/status/283014103189053442 Signal.trap("INT") { exit 1 } require 'lionel_richie' # Output message to $stderr, prefixed with the program name def pute(*args) first = args.shift.dup first.insert(0, "#{$0}: ") args.unshift(first) $stderr.puts(*args) end begin Lionel::CLI.start(ARGV) rescue GoogleDrive::Error, GoogleDrive::AuthenticationError => e @attempts ||= 0 @attempts += 1 Lionel::GoogleAuthentication.new.refresh if @attempts < 2 retry else puts e.class puts "-" * e.class.name.size pute e.message puts "Unable to access Google Drive" puts "run 'lionel authorize'" end rescue Trello::Error, Trello::InvalidAccessToken => e puts "Unable to access Trello" puts "run 'lionel authorize'" rescue StandardError => e puts e.class puts "-" * e.class.name.size pute e.message raise e end