Improve formatting of cli tool

This commit is contained in:
Brian Cain 2015-10-13 23:08:44 -07:00
parent beeac3858c
commit 221e5db6b5
5 changed files with 31 additions and 14 deletions

View file

@ -2,6 +2,7 @@
require 'rubygems'
require 'commander'
require 'pp'
require 'vmfloaty/auth'
require 'vmfloaty/pooler'
require 'vmfloaty/version'
@ -54,7 +55,7 @@ class Vmfloaty
unless os_types.nil?
response = Pooler.retrieve(verbose, os_types, token, url)
puts response
Format.get_hosts(response)
else
puts 'You did not provide an OS to get'
end
@ -90,8 +91,8 @@ class Vmfloaty
url = options.url ||= config['url']
hostname = args[0]
query = Pooler.query(verbose, url, hostname)
puts query
query_req = Pooler.query(verbose, url, hostname)
pp query_req
end
end
@ -113,8 +114,10 @@ class Vmfloaty
tags = JSON.parse(options.tags) if options.tags
token = options.token || config['token']
res_body = Pooler.modify(verbose, url, hostname, token, lifetime, tags)
puts res_body
modify_req = Pooler.modify(verbose, url, hostname, token, lifetime, tags)
if modify_req["ok"]
puts "Successfully modified vm #{hostname}."
end
end
end
@ -150,8 +153,8 @@ class Vmfloaty
hostname = args[0]
token = options.token ||= config['token']
res_body = Pooler.snapshot(verbose, url, hostname, token)
puts res_body
snapshot_req = Pooler.snapshot(verbose, url, hostname, token)
pp snapshot_req
end
end
@ -171,8 +174,8 @@ class Vmfloaty
token = options.token || config['token']
snapshot_sha = options.snapshot
res_body = Pooler.revert(verbose, url, hostname, token, snapshot_sha)
puts res_body
revert_req = Pooler.revert(verbose, url, hostname, token, snapshot_sha)
pp revert_req
end
end
@ -188,7 +191,7 @@ class Vmfloaty
url = options.url ||= config['url']
status = Pooler.status(verbose, url)
puts status
pp status
end
end
@ -204,7 +207,7 @@ class Vmfloaty
url = options.url ||= config['url']
summary = Pooler.summary(verbose, url)
puts summary
pp summary
end
end