[117607] trunk/base/src
snc at macports.org
snc at macports.org
Wed Mar 5 07:34:11 PST 2014
Revision: 117607
https://trac.macports.org/changeset/117607
Author: snc at macports.org
Date: 2014-03-05 07:34:11 -0800 (Wed, 05 Mar 2014)
Log Message:
-----------
base: add port select --summary, #36179
Modified Paths:
--------------
trunk/base/src/macports1.0/macports.tcl
trunk/base/src/port/port.tcl
Modified: trunk/base/src/macports1.0/macports.tcl
===================================================================
--- trunk/base/src/macports1.0/macports.tcl 2014-03-05 10:10:46 UTC (rev 117606)
+++ trunk/base/src/macports1.0/macports.tcl 2014-03-05 15:34:11 UTC (rev 117607)
@@ -4192,12 +4192,12 @@
}
# mportselect
-# * command: The only valid commands are list, set and show
+# * command: The only valid commands are list, set, show and summary
# * group: This argument should correspond to a directory under
# ${macports::prefix}/etc/select.
# * version: This argument is only used by the 'set' command.
# On error mportselect returns with the code 'error'.
-proc mportselect {command group {version {}}} {
+proc mportselect {command {group ""} {version {}}} {
ui_debug "mportselect \[$command] \[$group] \[$version]"
set conf_path ${macports::prefix}/etc/select/$group
@@ -4226,6 +4226,16 @@
}
return [lsort $lversions]
}
+ summary {
+ # Return the list of portgroups in ${macports::prefix}/etc/select
+ if {[catch {set lportgroups [glob -directory $conf_path -tails *]} result]} {
+ global errorInfo
+ ui_debug "${result}: $errorInfo"
+ return -code error [concat "No ports with the select" \
+ "option were found."]
+ }
+ return [lsort $lportgroups]
+ }
set {
# Use ${conf_path}/$version to read in sources.
if {$version eq {} || $version eq {base} || $version eq {current}
Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl 2014-03-05 10:10:46 UTC (rev 117606)
+++ trunk/base/src/port/port.tcl 2014-03-05 15:34:11 UTC (rev 117607)
@@ -463,7 +463,7 @@
# Execute the enclosed block once for every element in the portlist
# When the block is entered, the following variables will have been set:
-# portspec, porturl, portname, portversion, options, variations, requested_variations
+# portspec, porturl, portname, portversion, options, variations, requested_variations
proc foreachport {portlist block} {
set savedir [pwd]
foreach portspec $portlist {
@@ -2504,18 +2504,20 @@
proc action_select { action portlist opts } {
ui_debug "action_select \[$portlist] \[$opts]..."
- # Error out if no group is specified.
- if {[llength $portlist] < 1} {
- ui_error "port select \[--list|--set|--show] <group> \[<version>]"
+ array set opts_array $opts
+ set commands [array names opts_array ports_select_*]
+ array unset opts_array
+
+ # Error out if no group is specified or command is not --summary.
+ if {[llength $portlist] < 1 && [string map {ports_select_ ""} [lindex $commands 0]] != "summary"} {
+ ui_error "port select \[--list|--set|--show|--summary] \<group> \[<version>]"
return 1
}
+
set group [lindex $portlist 0]
-
- array set opts_array $opts
- set commands [array names opts_array ports_select_*]
- array unset opts_array
- # If no command (--set, --show, --list) is specified *but* more than one
- # argument is specified, default to the set command.
+
+ # If no command (--set, --show, --list, --summary) is specified *but*
+ # more than one argument is specified, default to the set command.
if {[llength $commands] < 1 && [llength $portlist] > 1} {
set command set
ui_debug [concat "Although no command was specified, more than " \
@@ -2601,6 +2603,41 @@
"'$selected_version'."]
return 0
}
+ summary {
+ if {[llength $portlist] > 0} {
+ ui_warn [concat "The 'summary' command does not expect any " \
+ "arguments. Extra arguments will be ignored."]
+ }
+
+ if {[catch {mportselect $command} portgroups]} {
+ ui_error "The 'summary' command failed: $portgroups"
+ return 1
+ }
+
+ set w1 4
+ set w2 8
+ set formatStr "%-*s %-*s %s"
+ puts [format $formatStr $w1 "Name" $w2 "Selected" "Options"]
+ foreach pg $portgroups {
+ if {[catch {mportselect list $pg} versions]} {
+ ui_error "The list of versions could not be obtained: $versions"
+ return 1
+ }
+
+ foreach v $versions {
+ if {[catch {mportselect show $pg} selected_version]} {
+ ui_error "The 'show' command failed: $selected_version"
+ return 1
+ }
+ }
+
+ set w1 [expr {max($w1, [string length $pg])}]
+ set w2 [expr {max($w2, [string length $selected_version])}]
+
+ puts [format $formatStr $w1 [string trim $pg] $w2 $selected_version [join $versions " "]]
+ }
+ return 0
+ }
default {
ui_error "An unknown command '$command' was specified."
return 1
@@ -4294,7 +4331,7 @@
clean {all archive dist work logs}
mirror {new}
lint {nitpick}
- select {list set show}
+ select {list set show summary}
log {{phase 1} {level 1}}
upgrade {force enforce-variants no-replace no-rev-upgrade}
rev-upgrade {id-loadcmd-check}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140305/ad5d8b18/attachment.html>
More information about the macports-changes
mailing list