Permalink
Browse files

By default, list nicknames as results

  • Loading branch information...
1 parent e3e621d commit a45092b2293d74976ff6072813769aeac1077c05 @joeyates committed Nov 12, 2010
Showing with 11 additions and 7 deletions.
  1. +9 −7 bin/rightstuff
  2. +2 −0 lib/rightstuff/base.rb
View
16 bin/rightstuff
@@ -11,14 +11,14 @@ include Rightstuff::Credentials
options = {
:credentials_subkey => nil,
- :show_all => false
+ :all => false
}
OptionParser.new do | opts |
opts.banner = "Usage: #{ $0 } [options] ACTION"
- opts.on( "-a", "--all", "Show all items, not only active ones" ) do | subkey |
- options[ :credentials_subkey ] = subkey.intern
+ opts.on( "-a", "--all", "Include all items" ) do | subkey |
+ options[ :all ] = true
end
opts.on( "-k", "--credentials-subkey=SUBKEY", "The subkey of the ~/.rightstuff file to use for authentication" ) do | subkey |
@@ -44,14 +44,16 @@ end
credentials = extract_credentials( options[ :credentials_subkey ] )
client = Rightstuff::Client.new( credentials )
-
action = ARGV.pop
case action
when 'servers'
- puts client.servers.inspect
-when 'arrays'
- puts client.arrays.inspect
+ servers = client.servers
+ servers.reject!{ | server | server.attributes[ :state ] != 'operational' }
+ puts servers.map{ | server | server.attributes[ :nickname ] }.join( "\n" )
+when 'server_arrays'
+ server_arrays = client.server_arrays
+ puts server_arrays.map{ | server_array | server_array.attributes[ :nickname ] }.join( "\n" )
when nil
raise 'No action supplied'
else
View
2 lib/rightstuff/base.rb
@@ -24,6 +24,8 @@ def self.extract_attributes( parent )
end
end
+ attr_reader :attributes
+
def initialize( client, item )
@client = client
@attributes = Base.extract_attributes( item )

0 comments on commit a45092b

Please sign in to comment.