#!/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' options = {} options[:cluster] = 'sandbox' 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 } end begin optparse.parse! mandatory = [:cluster] 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.show