mirror of
https://github.com/seejohnrun/haste-client.git
synced 2025-12-13 15:25:55 +00:00
Ability to give a file as first argument to haste-client
This patch makes it possible to either pipe data into the haste client, or just give a filename as first argument. Signed-off-by: Peter Haza
This commit is contained in:
16
lib/haste.rb
16
lib/haste.rb
@@ -12,8 +12,20 @@ module Haste
|
||||
|
||||
# Pull all of the data from STDIN
|
||||
def initialize
|
||||
@input = STDIN.readlines.join
|
||||
@input.strip!
|
||||
if STDIN.tty?
|
||||
if ARGV.empty?
|
||||
puts "No input file given"
|
||||
exit
|
||||
end
|
||||
|
||||
file = ARGV[0]
|
||||
abort "#{file} doesn't exist" unless File.exists?(file)
|
||||
|
||||
@input = open(file).read.strip
|
||||
else
|
||||
@input = STDIN.readlines.join
|
||||
@input.strip!
|
||||
end
|
||||
end
|
||||
|
||||
# Upload the and output the URL we get back
|
||||
|
||||
Reference in New Issue
Block a user