mirror of
https://github.com/seejohnrun/haste-client.git
synced 2026-02-10 09:31:33 +00:00
Initial work
This commit is contained in:
36
lib/haste.rb
Normal file
36
lib/haste.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
require 'restclient'
|
||||
require 'json'
|
||||
|
||||
module Haste
|
||||
|
||||
DEFAULT_URL = 'http://localhost:7777'
|
||||
|
||||
class CLI
|
||||
|
||||
attr_reader :input
|
||||
|
||||
# Pull all of the data from STDIN
|
||||
def initialize
|
||||
@input = STDIN.readlines.join
|
||||
@input.strip!
|
||||
end
|
||||
|
||||
# Upload the and output the URL we get back
|
||||
def start
|
||||
json = RestClient.post "#{server}/documents", input
|
||||
data = JSON.parse(json)
|
||||
puts "#{server}/#{data['key']}"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def server
|
||||
return @server if @server
|
||||
@server = ENV['HASTE_SERVER'] || Haste::DEFAULT_URL
|
||||
@server.chop! if server.end_with?('/')
|
||||
@server
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
5
lib/haste/version.rb
Normal file
5
lib/haste/version.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
module Haste
|
||||
|
||||
VERSION = '0.0.1'
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user