#!/usr/bin/env ruby require 'flattr' require 'launchy' options = { :git_dir => "#{Dir.pwd}/.git", :git_config => "#{Dir.pwd}/.git/config" } def error message puts "Error: #{message}" end class Git class < e puts e.message puts "Seems like you are missing a Flattr access token." puts "Browse to http://git-flattr.herokuapp.com and follow the instructions" print "Token: " token = gets end if token.nil? error "Invalid access token" exit 1 end Git.set_config "flattr.token", token.chomp end Flattr.configure do |config| config.access_token = Git.config 'flattr.token' end flattr = Flattr.new flattr.flattr Git.github_url thing = flattr.thing_lookup Git.github_url puts "Flattred #{Git.github_url} (#{thing.link})!" exit 0 rescue Flattr::Error::Unauthorized => e error e.message exit 1 rescue Flattr::Error::Forbidden => e error e.message exit 1 end