1
0
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:
Peter Haza
2011-11-29 20:28:30 +01:00
parent 7599baa5c5
commit ca02796551

View File

@@ -12,8 +12,20 @@ module Haste
# Pull all of the data from STDIN # Pull all of the data from STDIN
def initialize def initialize
@input = STDIN.readlines.join if STDIN.tty?
@input.strip! 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 end
# Upload the and output the URL we get back # Upload the and output the URL we get back