[41396] trunk/base/src/port/port.tcl

raimue at macports.org raimue at macports.org
Sat Nov 1 12:12:44 PDT 2008


Revision: 41396
          http://trac.macports.org/changeset/41396
Author:   raimue at macports.org
Date:     2008-11-01 12:12:44 -0700 (Sat, 01 Nov 2008)
Log Message:
-----------
port/port.tcl:
Add proc wraplabel which outputs a wrapped string with a label. Use the new
wrapping code for output of deps, platforms and maintainers.

Modified Paths:
--------------
    trunk/base/src/port/port.tcl

Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl	2008-11-01 18:29:13 UTC (rev 41395)
+++ trunk/base/src/port/port.tcl	2008-11-01 19:12:44 UTC (rev 41396)
@@ -489,6 +489,20 @@
     return [join $lines "\n"]
 }
 
+##
+# Wraps a line at a specified width with a label in front
+#
+# @see wrap
+#
+# @param label label for output
+# @param string input string
+# @param maxlen text width (0 defaults to current terminal width)
+# @return wrapped string
+proc wraplabel {label string maxlen {indent ""}} {
+    append label ": [string repeat " " [expr [string length $indent] - [string length "$label: "]]]"
+    return "$label[wrap $string $maxlen $indent 0]"
+}
+
 proc unobscure_maintainers { list } {
     set result {}
     foreach m $list {
@@ -1476,8 +1490,7 @@
                     append vars "$joiner$mod$v"
                     set joiner ", "
                 }
-                puts -nonewline "Variants:    "
-                puts [wrap $vars 0 [string repeat " " 13] 0]
+                puts [wraplabel "Variants" $vars 0 [string repeat " " 13]]
             }
             puts ""
             if {[info exists portinfo(long_description)]} {
@@ -1488,34 +1501,38 @@
                 }
             }
             if {[info exists portinfo(homepage)]} {
-                puts "Homepage:    $portinfo(homepage)"
+                puts [wraplabel "Homepage" $portinfo(homepage) 0 [string repeat " " 13]]
             }
             puts ""
             # Emit build, library, and runtime dependencies
+            # For wrapping, indent output at 22 chars
+            set label_len 22
             foreach {key title} {
                 depends_build "Build Dependencies"
                 depends_lib "Library Dependencies"
                 depends_run "Runtime Dependencies"
             } {
                 if {[info exists portinfo($key)]} {
-                    puts -nonewline "$title: "
+                    set depstr ""
                     set joiner ""
                     foreach d $portinfo($key) {
                         if {[macports::ui_isset ports_verbose]} {
-                            puts -nonewline "$joiner$d"
+                            append depstr "$joiner$d"
                         } else {
-                            puts -nonewline "$joiner[lindex [split $d :] end]"
+                            append depstr "$joiner[lindex [split $d :] end]"
                         }
                         set joiner ", "
                     }
                     set nodeps false
-                    puts ""
+                    puts [wraplabel $title $depstr 0 [string repeat " " $label_len]]
                 }
             }
                 
-            if {[info exists portinfo(platforms)]} { puts "Platforms: [join $portinfo(platforms) ", "]"}
+            if {[info exists portinfo(platforms)]} {
+                puts [wraplabel "Platforms" [join $portinfo(platforms) ", "] 0 [string repeat " " $label_len]]
+            }
             if {[info exists portinfo(maintainers)]} {
-                puts "Maintainers: [unobscure_maintainers $portinfo(maintainers)]"
+                puts [wraplabel "Maintainers" [unobscure_maintainers $portinfo(maintainers)] 0 [string repeat " " $label_len]]
             }
         }
         set separator "--\n"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20081101/6aadefed/attachment.html>


More information about the macports-changes mailing list