### Home Classes Methods

### In Files

- lib/haste/cli.rb

### Parent

Object

### Methods

- ::new
- #start

### Class/Module Index

Quicksearch

- Haste
- Haste::CLI
- Haste::Exception
- Haste::Uploader

No matching classes.

# Haste::CLI

### Public Class Methods

new() click to toggle source

Create a new uploader

    # File lib/haste/cli.rb, line 6
    def initialize
      @uploader = Uploader.new ENV['HASTE_SERVER']
    end

### Public Instance Methods

start() click to toggle source

And then handle the basic usage

    # File lib/haste/cli.rb, line 11
    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
      if ARGV.include?('--raw')
        url = "#{@uploader.server_url}/raw/#{key}"
      else
        url = "#{@uploader.server_url}/#{key}"
      end
      # And write data out
      if STDOUT.tty?
        STDOUT.puts url
      else
        STDOUT.print url
      end
    rescue Exception => e
      abort e.message
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.