Sha256: e63ef954ff314506516ad33a372b0e5acdeac99d20bf2a287e4fc085063ea4d4

Contents?: true

Size: 771 Bytes

Versions: 1

Compression:

Stored size: 771 Bytes

Contents

#!/usr/bin/env ruby

require 'boop'

def print_usage!
  warn "Usage:"
  warn "  boop paste [NAME]"
  warn "  boop html [NAME]"
  warn
  warn "Saves the contents of stdin to ~/.boop and does a `git push`."
  exit 1
end

if ARGV.include?('--help') || ARGV.include?('-h') || ARGV.length > 2
  print_usage!
end

if ENV['BOOP_URL'].nil? || ENV['BOOP_URL'].empty?
  warn "Please define the BOOP_URL environment variable."
  warn "(Set it to the URL pastes will be located under.)"
  exit 1
end

command, name = ARGV[0..1]

# Default to text paste.
command ||= :paste

boop = Boop.new(ENV['BOOP_URL'], "~/.boop")

case command.to_sym
when :html, :paste
  boop.send(command, name, $stdin.read)
when :file
  boop.file(File.basename(name), open(name).read)
else
  print_usage!
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
boop-0.5.0 exe/boop