Project

General

Profile

« Previous | Next » 

Revision a24bc5b1

Added by Marc Dequènes over 15 years ago

  • ID a24bc5b15ef38d0047f2624df1f195a63f48fc13

[evol] improved 'list' command

View differences:

bin/shadowwalker
def initialize
super('list', false)
self.short_desc = "list items of an object"
self.usages_params = [
"<object>",
self.short_desc = "list objects, and items/aspects/fields of an object"
self.usages_params = [
":objects",
":aspects <object>"
"<object>",
"<object> :aspects",
"<object> :fields"
]
end
......
exit 1
end
obj_hdl = args.shift.singularize
obj_hdl = args.shift.downcase.singularize
case obj_hdl
when ':object'
list = $ldapctl.objects
......
list.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)
list = obj_klass.possible_aspects
puts "=== List of LDAP aspects of #{subobj_human_name.pluralize} (#{list.size}) ==="
list.each do |subobj_name|
puts " - #{subobj_name}"
end
else
obj_klass = $ldapctl.find_klass(obj_hdl)
if obj_klass.nil?
......
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))
if args.empty?
obj_human_name = Translator.translate_object_name(obj_hdl)
Display.display_item_list("List of #{obj_human_name.pluralize}", obj_klass.find(:all))
else
subobj_hdl = args.shift.downcase.singularize
obj_human_name = Translator.translate_object_name(obj_hdl)
case subobj_hdl
when ':aspect'
list = obj_klass.possible_aspects
puts "=== List of LDAP Aspects of #{obj_human_name.pluralize} (#{list.size}) ==="
list.each do |aspect|
str = Translator.translate_aspect_name(aspect)
str += " [#{aspect}]" if $program_options[:handles]
puts " - #{str}"
end
when ':field'
list = obj_klass.possible_attributes
puts "=== List of LDAP Fields of #{obj_human_name.pluralize} (#{list.size}) ==="
list.each do |field|
str = Translator.translate_field_name(field)
str += " [#{field}]" if $program_options[:handles]
puts " - #{str}"
end
obj_klass.possible_aspects.each do |aspect|
aspect_human_name = Translator.translate_aspect_name(aspect)
list = obj_klass.possible_attributes_for_aspect(aspect)
puts "--- Sublist of LDAP Fields for Aspect #{aspect_human_name} (#{list.size}) ---"
list.each do |field|
str = Translator.translate_field_name(field)
str += " [#{field}]" if $program_options[:handles]
puts " - #{str}"
end
end
else
end
end
end
end
end

Also available in: Unified diff