1. Michael Granger
  2. treequel-shell

Commits

Michael Granger  committed ab1f1b7 Merge

Merged with 28576726289e

  • Participants
  • Parent commits f2d6d01, 91851c0
  • Branches default
  • Tags v1.5.3

Comments (0)

Files changed (1)

File bin/treewhat

View file
  • Ignore whitespace
 
 	### Display a schema artifact in a readable way.
 	def display_schema_artifact( artifact )
-		self.prompt.say( artifact.class.name.sub(/.*::/, '') + ' ' )
-		self.prompt.say( artifact.to_s )
+		self.prompt.say( self.prompt.color(artifact.class.name.sub(/.*::/, ''), :header) + ' ' )
+		self.prompt.say( self.prompt.color(artifact.to_s, :subheader) )
+
+		# Display some other stuff depending on what kind of thing it is
+		case artifact
+		when Treequel::Schema::AttributeType
+			self.display_attrtype_details( artifact )
+		end
+	end
+
+
+	### Display additional details for the specified +attrtype+.
+	### @param [Treequel::Schema::AttributeType] attrtype  the attribute type object to display
+	def display_attrtype_details( attrtype )
+		ocs = self.directory.schema.object_classes.values.find_all do |oc|
+			( oc.must_oids | oc.may_oids ).include?( attrtype.name.to_sym )
+		end
+
+		if ocs.empty?
+			self.prompt.say "No objectClasses with the '%s' attribute are in the current schema." %
+				[ attrtype.name ]
+		else
+			ocnames = ocs.uniq.map( &:name ).map( &:to_s ).sort
+
+			self.prompt.say "objectClasses with the '%s' attribute in the current schema:" %
+				[ attrtype.name ]
+			self.prompt.say( self.prompt.list(ocnames, :columns_across) )
+		end
 	end