Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support '-' to read from STDIN

  • Loading branch information...
commit 447f735d7cbc25f3d7f5f8715ddf851d27e0dc06 1 parent 7be4a12
@ConradIrwin authored
Showing with 13 additions and 9 deletions.
  1. +13 −9 bin/gist
View
22 bin/gist
@@ -124,17 +124,21 @@ begin
if options[:paste]
puts Gist.gist(Gist.paste, options)
- elsif ARGV.size == 0
- $stderr.puts "(type a gist. <ctrl-c> to cancel, <ctrl-d> when done)" if $stdin.tty?
- puts Gist.gist(ARGF.read, options)
else
+ to_read = ARGV.empty? ? ['-'] : ARGV
files = {}
- ARGV.zip(filenames).each do |(file, name)|
- files[name || file] = begin
- File.read(File.expand_path(file))
- rescue => e
- raise e.extend(Gist::Error)
- end
+ to_read.zip(filenames).each do |(file, name)|
+ files[name || file] =
+ begin
+ if file == '-'
+ $stderr.puts "(type a gist. <ctrl-c> to cancel, <ctrl-d> when done)" if $stdin.tty?
+ STDIN.read
+ else
+ File.read(File.expand_path(file))
+ end
+ rescue => e
+ raise e.extend(Gist::Error)
+ end
end
puts Gist.multi_gist(files, options)
Please sign in to comment.
Something went wrong with that request. Please try again.