From b00f8e65e758e8b8adfb82159d4f6096a8f90afa Mon Sep 17 00:00:00 2001 From: Postmodern Date: Tue, 25 Jun 2013 17:11:28 -0700 Subject: [PATCH] Added option parsing to bin/fog. * Added -V, --version * Added -h, --help --- bin/fog | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bin/fog b/bin/fog index c57f9b7b5..7f82de0e6 100755 --- a/bin/fog +++ b/bin/fog @@ -1,7 +1,25 @@ #!/usr/bin/env ruby + require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'fog')) +require 'optparse' require 'irb' require 'yaml' + +options = OptionParser.new do |opts| + opts.banner = 'usage: fog [options] GROUP' + + opts.on_tail('-V', '--version', 'Prints the version') do + puts Fog::VERSION + exit + end + + opts.on_tail('-h', '--help', 'Prints this message') do + puts opts + exit + end +end +options.parse! + Fog.credential = ARGV.first ? ARGV.first.to_sym : nil Fog.mock! if ENV['FOG_MOCK'] if Fog.credentials.empty?