summaryrefslogtreecommitdiffstats
path: root/lib/puppet/application/ralsh.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/application/ralsh.rb')
-rw-r--r--lib/puppet/application/ralsh.rb34
1 files changed, 9 insertions, 25 deletions
diff --git a/lib/puppet/application/ralsh.rb b/lib/puppet/application/ralsh.rb
index 6ad520dca..b9f7a587c 100644
--- a/lib/puppet/application/ralsh.rb
+++ b/lib/puppet/application/ralsh.rb
@@ -38,25 +38,15 @@ Puppet::Application.new(:ralsh) do
end
command(:main) do
- if ARGV.length > 0
- type = ARGV.shift
- else
- raise "You must specify the type to display"
- end
-
- name = nil
+ type = ARGV.shift or raise "You must specify the type to display"
+ typeobj = Puppet::Type.type(type) or raise "Could not find type #{type}"
+ name = ARGV.shift
params = {}
- if ARGV.length > 0
- name = ARGV.shift
- end
-
- if ARGV.length > 0
- ARGV.each do |setting|
- if setting =~ /^(\w+)=(.+)$/
- params[$1] = $2
- else
- raise "Invalid parameter setting %s" % setting
- end
+ ARGV.each do |setting|
+ if setting =~ /^(\w+)=(.+)$/
+ params[$1] = $2
+ else
+ raise "Invalid parameter setting %s" % setting
end
end
@@ -64,12 +54,6 @@ Puppet::Application.new(:ralsh) do
raise "You cannot edit a remote host"
end
- typeobj = nil
-
- unless typeobj = Puppet::Type.type(type)
- raise "Could not find type %s" % type
- end
-
properties = typeobj.properties.collect { |s| s.name }
format = proc {|trans|
@@ -106,7 +90,7 @@ Puppet::Application.new(:ralsh) do
transbucket.sort { |a,b| a.name <=> b.name }.collect(&format)
else
if name
- obj = typeobj.new(:name => name, :check => properties)
+ obj = typeobj.instances.find { |o| o.name == name } || typeobj.new(:name => name, :check => properties)
vals = obj.retrieve
unless params.empty?