#!/usr/bin/env ruby dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir) require 'trigger' require 'optparse' COMMANDS = %w(start stop) options = {}.tap do |options| OptionParser.new do |opts| opts.version = Trigger::VERSION opts.banner = 'Usage: trigger command [options]' opts.separator "" opts.separator "Options:" opts.on("-d", "--daemon", "Runs trigger as a daemon") do |user_agent| options[:daemon] = true end end.parse! end client = Trigger::Client.new(options) if command = ARGV[0] client.public_send(command) else abort 'No command specified' end