def perform_gist
type_map = { :ruby => "rb", :c => "c", :plain => "plain" }
if self.content =~ /\A\s*\z/
raise CommandError, "Found no code to gist."
end
begin
extname = opts.present?(:file) ? ".#{gist_file_extension(opts[:f])}" : ".#{type_map[self.code_type]}"
if opts.present?(:lines)
self.content = restrict_to_lines(content, opts[:l])
end
link = Gist.write([:extension => extname,
:input => self.content],
!opts[:p])
rescue SystemExit
end
if link
Gist.copy(link)
output.puts "Gist created at #{link} and added to clipboard."
end
end