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

raimue at macports.org raimue at macports.org
Fri Feb 22 17:17:47 PST 2008


Revision: 34391
          http://trac.macosforge.org/projects/macports/changeset/34391
Author:   raimue at macports.org
Date:     2008-02-22 17:17:47 -0800 (Fri, 22 Feb 2008)

Log Message:
-----------
port/port.tcl:
Overhaul port search output:
 * If requesting multiple ports, seperate searches with "--"
 * New output format which is easier to read
 * Wrap description at 80 characters per line for easier reading

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

Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl	2008-02-23 01:00:07 UTC (rev 34390)
+++ trunk/base/src/port/port.tcl	2008-02-23 01:17:47 UTC (rev 34391)
@@ -388,12 +388,13 @@
 # @see wrapline
 #
 # @param string input string
-# @param maxlen text width
+# @param maxlen text width (indent length not counted)
+# @param indent prepend to every line
 # @return wrapped string
-proc wrap {string maxlen} {
+proc wrap {string maxlen {indent ""}} {
     set splitstring {}
     foreach line [split $string "\n"] {
-        lappend splitstring [wrapline $line $maxlen]
+        lappend splitstring [wrapline $line $maxlen $indent]
     }
     return [join $splitstring "\n"]
 }
@@ -404,15 +405,16 @@
 # @see wrap
 #
 # @param line input line
-# @param maxlen text width
+# @param maxlen text width (indent length not counted)
+# @param indent prepend to every line
 # @return wrapped string
-proc wrapline {line maxlen} {
+proc wrapline {line maxlen {indent ""}} {
     set string [split $line " "]
-    set newline [list [lindex $string 0]]
+    set newline [list $indent [lindex $string 0]]
     foreach word [lrange $string 1 end] {
         if {[string length $newline]+[string length $word] > $maxlen} {
             lappend lines [join $newline " "]
-            set newline {}
+            set newline [list $indent]
         }
         lappend newline $word
     }
@@ -1908,13 +1910,17 @@
         return 1
     }
     
+    set separator ""
     foreachport $portlist {
+        puts -nonewline $separator
+
         set portfound 0
         if {[catch {set res [mportsearch $portname no]} result]} {
             global errorInfo
             ui_debug "$errorInfo"
             break_softcontinue "search for portname $portname failed: $result" 1 status
         }
+        set joiner ""
         foreach {name array} $res {
             array unset portinfo
             array set portinfo $array
@@ -1932,17 +1938,30 @@
                 puts "Invalid port entry for $portinfo(name), missing version"
                 continue
             }
-            if {![info exists portinfo(portdir)]} {
-                set output [format "%-30s %-12s %s" $portinfo(name) $portinfo(version) [join $portinfo(description)]]
+
+            if {[macports::ui_isset ports_quiet]} {
+                puts $portinfo(name)
             } else {
-                set output [format "%-30s %-14s %-12s %s" $portinfo(name) $portinfo(portdir) $portinfo(version) [join $portinfo(description)]]
+                puts -nonewline $joiner
+
+                puts -nonewline "$portinfo(name) @$portinfo(version)"
+                if {[info exists portinfo(categories)]} {
+                    puts -nonewline " ([join $portinfo(categories) ", "])"
+                }
+                puts ""
+                puts [wrap [join $portinfo(description)] 76 [string repeat " " 4]]
             }
+
+            set joiner "\n"
             set portfound 1
-            puts $output
         }
         if { !$portfound } {
             ui_msg "No match for $portname found"
+        } elseif {[llength $res] > 1} {
+            ui_msg "\nFound [llength $res] ports."
         }
+
+        set separator "--\n"
     }
     
     return $status

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080222/26772049/attachment-0001.html 


More information about the macports-changes mailing list