Project

General

Profile

« Previous | Next » 

Revision a9b44a39

Added by Marc Dequènes over 15 years ago

  • ID a9b44a390fbf6ddb89fd0cf0cce9f5a4f0cb4dbe

[evol] code cleanup

View differences:

bin/shadowwalker
cmdparser.add_command(CmdParse::HelpCommand.new)
cmdparser.add_command(CmdParse::VersionCommand.new)
I18n.load_path += Dir[File.join(LdapShadows::Config::DATA_DIR, "*.yml")]
I18n.default_locale = :en
ldapctl = Controller.new
ldapctl.set_global_config(config[:presentation])
config[:aspects].each_pair do |aspect_name, aspect_data|
......
end
ldapctl.load_relations
def translate_object_name(obj_hdl)
I18n.t(obj_hdl, :scope => 'objects', :default => "Object '#{obj_hdl}'")
end
cmd = CmdParse::Command.new('list', false)
cmd.short_desc = "list objects"
cmd.set_execution_block do |args|
......
exit 2
end
obj_human_name = translate_object_name(obj_hdl)
puts "=== List of #{obj_human_name.pluralize} ==="
obj_klass.find(:all).each do |obj|
str = obj.human_name
str += " [#{obj.name}]" if $program_options[:handles]
str += ": #{obj.description}" unless obj.description.empty?
puts str
end
obj_human_name = Translator.translate_object_name(obj_hdl)
Display.display_item_list("List of " + obj_human_name.pluralize, obj_klass.find(:all))
end
cmdparser.add_command(cmd)
def translate_field_name(field_name)
if field_name.index(":")
type, key = field_name.split(":")
case type
when 'rel'
I18n.t(key, :scope => 'relations', :default => field_name)
else
raise "Cannot translate unknown data key type"
end
else
att = ActiveLdap::Base.schema.attribute(field_name)
I18n.t(att.human_attribute_name, :scope => 'attribute_types', :default => att.human_attribute_description)
end
end
def translate_aspect_name(aspect_name)
I18n.t(aspect_name, :scope => 'aspects', :default => "Aspect '#{aspect_name}'")
end
cmd = CmdParse::Command.new('show', false)
cmd.short_desc = "show object information"
cmd.set_execution_block do |args|

Also available in: Unified diff