Sha256: 65a4144fd62bbd90cbfec1121831e20430891dd70ab5dfbfa442567413daa9b5

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

#!/usr/bin/env ruby

$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'optparse'
require 'mouth'
require 'mouth/runner'
require 'mouth/sucker'

options = {
  :verbosity => 0,
  :host => "localhost",
  :port => 8889
}

parser = OptionParser.new do |op|
  op.banner = "Usage: mouth [options]"

  op.separator "Mouth version: #{Mouth::VERSION}"
  op.separator ""
  op.separator "Options:"

  ##
  ## Daemonization / Logging options
  ##

  op.on("--pidfile PATH", "DO YOU WANT ME TO WRITE A PIDFILE SOMEWHERE FOR U?") do |pid_file|
    options[:pid_file] = pid_file
  end
  
  op.on("--logfile PATH", "I'LL POOP OUT LOGS HERE FOR U") do |log_file|
    options[:log_file] = log_file
  end
  
  op.on("-v", "--verbosity LEVEL", "HOW MUCH POOP DO U WANT IN UR LOGS? [LEVEL=0:errors,1:some,2:lots of poop]") do |verbosity|
    options[:verbosity] = verbosity.to_i
  end
  
  op.on("-K", "--kill", "SHUT THE MOUTH") do
    options[:kill] = true
  end
  
  ##
  ## Socket to suck from
  ##
  
  op.on("-H", "--host HOST", "I SUCK ON THIS NETWORK INTERFACE") do |host|
    options[:host] = host
  end
  
  op.on("-P", "--port PORT", "I SUCK FROM THIS HOLE") do |port|
    options[:port] = port.to_i
  end
  
  ##
  ## Mongo
  ##
  op.on("--mongodb DATABASE", "STORE SUCKINGS IN THIS DB") do |mongo_db|
    options[:mongo_db] = mongo_db
  end
  
  # NOTE: this option can be given multiple times for a replica set
  op.on("--mongohost HOSTPORT", "STORE SUCKINGS IN THIS MONGO") do |mongo_host|
    options[:mongo_hosts] ||= []
    options[:mongo_hosts] << mongo_host
  end

  op.on("-h", "--help", "I WANT MOAR HALP") do
    puts op
    exit
  end

  op.separator ""
end

parser.parse!

Mouth::Runner.new(options).run!

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mouth-0.8.1 bin/mouth