Sha256: 4942fde38081dc92c57715f67ad8450dc450f05c4a5fbe0b807b57bee58d10bd
Contents?: true
Size: 1.96 KB
Versions: 3
Compression:
Stored size: 1.96 KB
Contents
#!/usr/bin/env ruby dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir) require 'buildbox' require 'optparse' commands = {} options = {} help = <<HELP auth # authentication (login, logout) monitor # monitor builds (start, stop) version # display version HELP global = OptionParser.new do |opts| opts.version = Buildbox::VERSION opts.banner = 'Usage: buildbox COMMAND [command-specific-actions]' opts.separator help end commands['auth:login'] = OptionParser.new do |opts| opts.banner = "Usage: buildbox auth:login API_KEY" end commands['auth:logout'] = OptionParser.new do |opts| opts.banner = "Usage: buildbox auth:logout" end commands['monitor:start'] = OptionParser.new do |opts| opts.banner = "Usage: buildbox monitor:start" opts.on("-d", "--daemon", "Runs as a daemon") do options[:daemon] = true end opts.on("--help", "You're looking at it.") do puts commands['monitor:start'] exit end end commands['monitor:stop'] = OptionParser.new do |opts| opts.banner = "Usage: buildbox monitor:stop" end commands['version'] = OptionParser.new do |opts| opts.banner = "Usage: buildbox version" end global.order! args = ARGV if command = args.shift if commands.has_key?(command) commands[command].parse! else puts "`#{command}` is an unknown command" exit 1 end if command == "version" puts Buildbox::VERSION exit end if command =~ /^monitor/ client = Buildbox::Client.new(options) if command == "monitor:start" client.start elsif command == "monitor:stop" client.stop end end if command =~ /^auth/ auth = Buildbox::Auth.new if command == "auth:login" api_key = args[0] unless api_key puts commands['auth:login'] exit end auth.login(:api_key => args[0]) elsif command == "auth:logout" auth.logout end end else puts global.help end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
buildbox-0.0.4 | bin/buildbox |
buildbox-0.0.3 | bin/buildbox |
buildbox-0.0.2 | bin/buildbox |