Revision 6089b33a
Added by Marc Dequènes over 15 years ago
- ID 6089b33a753e7b3d548686ab36e99843cfea0283
bin/shadowwalker | ||
---|---|---|
cmd = CmdParse::Command.new('list', false)
|
||
cmd.short_desc = "list objects"
|
||
cmd.set_execution_block do |args|
|
||
if args.size != 1
|
||
if args.size < 1
|
||
STDERR.puts "syntax error: no object name given"
|
||
exit 1
|
||
end
|
||
|
||
obj_hdl = args.shift.singularize
|
||
obj_klass = ldapctl.find_klass(obj_hdl)
|
||
if obj_klass.nil?
|
||
STDERR.puts "No such object '#{obj_hdl}'."
|
||
exit 2
|
||
end
|
||
case obj_hdl
|
||
when ':object'
|
||
puts "=== List of LDAP objects ==="
|
||
ldapctl.objects.each do |obj_name|
|
||
puts " - #{obj_name}"
|
||
end
|
||
when ':aspect'
|
||
if args.empty?
|
||
STDERR.puts "syntax error: no sub-object name given"
|
||
exit 1
|
||
end
|
||
|
||
subobj_hdl = args.shift.singularize
|
||
obj_klass = ldapctl.find_klass(subobj_hdl)
|
||
if obj_klass.nil?
|
||
STDERR.puts "No such object '#{obj_hdl}'."
|
||
exit 2
|
||
end
|
||
|
||
subobj_human_name = Translator.translate_object_name(subobj_hdl)
|
||
puts "=== List of LDAP aspects of #{subobj_human_name.pluralize} ==="
|
||
obj_klass.possible_aspects.each do |subobj_name|
|
||
puts " - #{subobj_name}"
|
||
end
|
||
else
|
||
obj_klass = ldapctl.find_klass(obj_hdl)
|
||
if obj_klass.nil?
|
||
STDERR.puts "No such object '#{obj_hdl}'."
|
||
exit 2
|
||
end
|
||
|
||
obj_human_name = Translator.translate_object_name(obj_hdl)
|
||
Display.display_item_list("List of " + obj_human_name.pluralize, obj_klass.find(:all))
|
||
obj_human_name = Translator.translate_object_name(obj_hdl)
|
||
Display.display_item_list("List of #{obj_human_name.pluralize}", obj_klass.find(:all))
|
||
end
|
||
end
|
||
cmdparser.add_command(cmd)
|
||
|
Also available in: Unified diff
[evol] added list of available objects and aspects of objects, and s/ou/unit/ object