#!/usr/bin/env ruby lib = File.expand_path('../../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'rubygems' require 'contexto' require 'optparse' require 'English' $stderr.sync = true options = {} options[:console] = false options[:bash] = false options[:ssh] = false optparse = OptionParser.new do |opts| opts.banner = 'Usage: contexto [options]' opts.on('-c', '--cluster CLUSTER', 'Cluster') { |v| options[:cluster] = v } opts.on('-s', '--service SERVICE', 'Service') { |v| options[:service] = v } opts.on('-t', '--container CONTAINER', 'Container') { |v| options[:container] = v } opts.on('-r', '--rake COMMAND', 'Rake command') { |v| options[:rake] = v } opts.on('-b', '--console') { options[:console] = true } opts.on('-e', '--bash') { options[:bash] = true } opts.on('-f', '--ssh') { options[:ssh] = true } end begin optparse.parse! mandatory = [] missing = mandatory.select { |param| options[param].nil? } unless missing.empty? raise OptionParser::MissingArgument.new(missing.join(', ')) end rescue OptionParser::InvalidOption, OptionParser::MissingArgument puts $ERROR_INFO.to_s puts optparse exit end c = Contexto::Contextualize.new(options) c.run