mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-26 02:12:33 +01:00
Added support to cloudapp for uploading stdin.
This commit is contained in:
parent
757fa3314d
commit
e552802051
1 changed files with 14 additions and 2 deletions
|
|
@ -45,16 +45,28 @@ end
|
||||||
if ARGV[0].nil?
|
if ARGV[0].nil?
|
||||||
puts "You need to specify a file to upload."
|
puts "You need to specify a file to upload."
|
||||||
exit!(1)
|
exit!(1)
|
||||||
|
elsif ARGV[0] == '-'
|
||||||
|
if ARGV[1].nil?
|
||||||
|
puts "You need to specify a filename for the input stream."
|
||||||
|
puts "Example usage: echo \"Hello\" | cloudapp - hello.txt"
|
||||||
|
exit!(1)
|
||||||
|
end
|
||||||
|
file = "/tmp/#{ARGV[1]}"
|
||||||
|
f = open(file, File::CREAT | File::WRONLY | File::BINARY)
|
||||||
|
f.write STDIN.read
|
||||||
|
f.close
|
||||||
|
else
|
||||||
|
file = ARGV[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
CloudApp.authenticate(email,password)
|
CloudApp.authenticate(email,password)
|
||||||
url = CloudApp::Item.create(:upload, {:file => ARGV[0]}).url
|
url = CloudApp::Item.create(:upload, {:file => file}).url
|
||||||
|
|
||||||
# Say it for good measure.
|
# Say it for good measure.
|
||||||
puts "Uploaded to #{url}."
|
puts "Uploaded to #{url}."
|
||||||
|
|
||||||
# Get the embed link.
|
# Get the embed link.
|
||||||
url = "#{url}/#{ARGV[0].split('/').last}"
|
url = "#{url}/#{file.split('/').last}"
|
||||||
|
|
||||||
# Copy it to your (Mac's) clipboard.
|
# Copy it to your (Mac's) clipboard.
|
||||||
`echo '#{url}' | tr -d "\n" | pbcopy`
|
`echo '#{url}' | tr -d "\n" | pbcopy`
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue