Skip to content

Commit

Permalink
v4.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradIrwin committed Nov 19, 2015
1 parent 59c0b8f commit 5b19eed
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 20 deletions.
40 changes: 38 additions & 2 deletions build/gist
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ end
module Gist
extend self

VERSION = '4.4.2'
VERSION = '4.5.0'

# A list of clipboard commands with copy and paste support.
CLIPBOARD_COMMANDS = {
Expand Down Expand Up @@ -1507,6 +1507,28 @@ module Gist

end

def read_gist(id, file_name=nil)
url = "#{base_path}/gists/#{id}"
request = Net::HTTP::Get.new(url)
response = http(api_url, request)

if response.code == '200'
body = JSON.parse(response.body)
files = body["files"]

if file_name
file = files[file_name]
raise Error, "Gist with id of #{id} and file #{file_name} does not exist." unless file
else
file = files.values.first
end

puts file["content"]
else
raise Error, "Gist with id of #{id} does not exist."
end
end

def get_gist_pages(url)

request = Net::HTTP::Get.new(url)
Expand Down Expand Up @@ -1820,7 +1842,10 @@ end

# Silence Ctrl-C's
trap('INT'){ exit 1 }
trap('PIPE', 'EXIT')

if Signal.list.include? 'PIPE'
trap('PIPE', 'EXIT')
end

require 'optparse'

Expand Down Expand Up @@ -1863,6 +1888,7 @@ original gist with the same GitHub account.
Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-R] [-d DESC] [-a] [-u URL] [-P] [-f NAME|-t EXT]* FILE*
#{executable_name} --login
#{executable_name} [-l|-r]
EOS

Expand Down Expand Up @@ -1932,6 +1958,10 @@ Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-R] [-d DESC] [-a] [-u URL] [-P]
options[:list] = user
end

opts.on("-r", "--read ID [FILENAME]", "Read a gist and print out the contents") do |id|
options[:read] = id
end

opts.on_tail("-h","--help", "Show this message.") do
puts opts
exit
Expand Down Expand Up @@ -1970,6 +2000,12 @@ begin
exit
end

if options.key? :read
file_name = ARGV.first
Gist.read_gist(options[:read], file_name)
exit
end

if options[:paste]
puts Gist.gist(Gist.paste, options)
else
Expand Down
18 changes: 1 addition & 17 deletions build/gist.1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GIST" "1" "July 2015" "" "Gist manual"
.TH "GIST" "1" "November 2015" "" "Gist manual"
.
.SH "NAME"
\fBgist\fR \- upload code to https://gist\.github\.com
Expand Down Expand Up @@ -123,22 +123,6 @@ Success! https://github\.com/settings/applications
.IP "" 0
.
.P
You can read the 2\-factor auth code from an sms or the authentication app, depending on how you set your account up \fIhttps://github\.com/settings/admin\fR\.
.
.P
Note: 2\-factor authentication just appeared recently \fIhttps://github\.com/blog/1614\-two\-factor\-authentication\fR, so if you run into errors, update the gist gem\.
.
.IP "" 4
.
.nf

gem update gist
.
.fi
.
.IP "" 0
.
.P
This token is stored in \fB~/\.gist\fR and used for all future gisting\. If you need to you can revoke it from https://github\.com/settings/applications, or just delete the file\. If you need to store tokens for both github\.com and a Github Enterprise instance you can save your Github Enterprise token in \fB~/\.gist\.github\.example\.com\fR where "github\.example\.com" is the URL for your Github Enterprise instance\.
.
.IP "\(bu" 4
Expand Down
2 changes: 1 addition & 1 deletion lib/gist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
module Gist
extend self

VERSION = '4.4.2'
VERSION = '4.5.0'

# A list of clipboard commands with copy and paste support.
CLIPBOARD_COMMANDS = {
Expand Down

0 comments on commit 5b19eed

Please sign in to comment.