Class: Haste::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/haste/cli.rb

Instance Method Summary collapse

Constructor Details

#initializeCLI

Create a new uploader



6
7
8
9
10
11
12
13
14
# File 'lib/haste/cli.rb', line 6

def initialize
  @uploader = Uploader.new(
    ENV['HASTE_SERVER'],
    ENV['HASTE_SERVER_TOKEN'],
    ENV['HASTE_SHARE_SERVER'],
    ENV['HASTE_USER'],
    ENV['HASTE_PASS'],
    ENV['HASTE_SSL_CERTS'])
end

Instance Method Details

#startObject

And then handle the basic usage



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/haste/cli.rb', line 17

def start
  # Take data in
  if STDIN.tty?
    key = @uploader.upload_path ARGV.first
  else
    key = @uploader.upload_raw STDIN.readlines.join
  end
  # Put together a URL
  url = "#{@uploader.share_server_url}/share/#{key}"
  # And write data out
  if STDOUT.tty?
    STDOUT.puts url
  else
    STDOUT.print url
  end
rescue Exception => e
  abort e.message
end