Sha256: add92c9422f676f362cfc756f1623e5ab3921df002c07a68fac9f6ec2954d487

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

#!/usr/bin/env ruby

require File.join(File.dirname(__FILE__), '../lib/smartcloud')
require 'pp'

if !ENV['SMARTCLOUD_USERNAME'] || !ENV['SMARTCLOUD_PASSWORD']
  puts "Please set environment variables SMARTCLOUD_PASSWORD and SMARTCLOUD_USERNAME in your environment."
  exit(1)
end

if ARGV.size == 1
  @cmd=ARGV[0]
elsif ARGV.size == 2
  @cmd="#{ARGV[0]}('#{ARGV[1]}')"
elsif ARGV.size == 0 
  puts %{
  Usage: 
  smartcloud help
  smartcloud help [command]
  smartcloud [command]
  smartcloud [command] [argument]

  Examples:
  smartcloud "delete_instance(12345)"
  smartcloud delete_instance 12345
  smartcloud delete_instances 12345 12346 12347
  smartcloud "delete_instances(12345,12346,12347)"
  smartcloud display_instances
}
  exit(0)
else
  @cmd="#{ARGV[0]}(#{ARGV[1..-1].map {|item| "'#{item}'"}.join(',')})"
end

  # allows us to send arbitrary commands like
  # smartcloud username password describe_instance("122345")
  result = eval("@smartcloud.#{@cmd}")

  if result == true || result.nil?
    # do nothing, the command already logged
  else
    if result.is_a?(String)
      puts result
    else
      puts result.pretty_inspect
    end
  end

Version data entries

4 entries across 2 versions & 1 rubygems

Version Path
cft_smartcloud-0.2.2 bin/smartcloud
cft_smartcloud-0.2.2 bin/cft_smartcloud
cft_smartcloud-0.1.9 bin/cft_smartcloud
cft_smartcloud-0.1.9 bin/smartcloud