lib/badger/cli.rb in badgerbadgerbadger-0.3.0 vs lib/badger/cli.rb in badgerbadgerbadger-0.3.1
- old
+ new
@@ -30,10 +30,23 @@
option :not, desc: 'Exclude these services (comma-separated list)'
option :only, desc: 'Generate for *only* these services (comma-separated list)'
option :also, desc: 'Include this extra service (currently only \'mit\')'
def badge dir = '.'
- @badger = Badger.new Git.open(dir).remote.url
+ begin
+ @g = Git.open(dir)
+ rescue ArgumentError
+ puts 'Run this from inside a git repo'
+ exit 1
+ end
+
+ @r = @g.remote.url
+ if @r.nil?
+ puts 'This repo does not appear to have a github remote'
+ exit 2
+ end
+ @badger = Badger.new @r
+
@badger.remove options[:not].split(',') if options[:not]
@badger.only options[:only].split(',') if options[:only]
@badger.also options[:also].split(',') if options[:also]
spec_file = (Dir.entries dir).select { |i| /gemspec/.match i }[0]
\ No newline at end of file