Ticket #36179: base-select-summary.3.diff

File base-select-summary.3.diff, 5.2 KB (added by raimue (Rainer Müller), 10 years ago)

Version 2 of the patch returned one portgroup only, moved the return statement to the correct location

  • src/macports1.0/macports.tcl

     
    41924192}
    41934193
    41944194# mportselect
    4195 #   * command: The only valid commands are list, set and show
     4195#   * command: The only valid commands are list, set, show and summary
    41964196#   * group: This argument should correspond to a directory under
    41974197#            ${macports::prefix}/etc/select.
    41984198#   * version: This argument is only used by the 'set' command.
    41994199# On error mportselect returns with the code 'error'.
    4200 proc mportselect {command group {version {}}} {
     4200proc mportselect {command {group ""} {version {}}} {
    42014201    ui_debug "mportselect \[$command] \[$group] \[$version]"
    42024202
    42034203    set conf_path ${macports::prefix}/etc/select/$group
     
    42264226            }
    42274227            return [lsort $lversions]
    42284228        }
     4229        summary {
     4230            # Return the list of portgroups in ${macports::prefix}/etc/select
     4231            if {[catch {set lportgroups [glob -directory $conf_path -tails *]} result]} {
     4232                global errorInfo
     4233                ui_debug "${result}: $errorInfo"
     4234                return -code error [concat "No ports with the select" \
     4235                                           "option were found."]
     4236            }
     4237            return [lsort $lportgroups]
     4238        }
    42294239        set {
    42304240            # Use ${conf_path}/$version to read in sources.
    42314241            if {$version eq {} || $version eq {base} || $version eq {current}
  • src/port/port.tcl

     
    463463
    464464# Execute the enclosed block once for every element in the portlist
    465465# When the block is entered, the following variables will have been set:
    466 #       portspec, porturl, portname, portversion, options, variations, requested_variations
     466#   portspec, porturl, portname, portversion, options, variations, requested_variations
    467467proc foreachport {portlist block} {
    468468    set savedir [pwd]
    469469    foreach portspec $portlist {
     
    25042504proc action_select { action portlist opts } {
    25052505    ui_debug "action_select \[$portlist] \[$opts]..."
    25062506
    2507     # Error out if no group is specified.
    2508     if {[llength $portlist] < 1} {
    2509         ui_error "port select \[--list|--set|--show] <group> \[<version>]"
     2507    array set opts_array $opts
     2508    set commands [array names opts_array ports_select_*]
     2509    array unset opts_array
     2510
     2511    # Error out if no group is specified or command is not --summary.
     2512    if {[llength $portlist] < 1 && [string map {ports_select_ ""} [lindex $commands 0]] != "summary"} {
     2513        ui_error "port select \[--list|--set|--show|--summary] \<group> \[<version>]"
    25102514        return 1
    25112515    }
     2516
    25122517    set group [lindex $portlist 0]
    2513 
    2514     array set opts_array $opts
    2515     set commands [array names opts_array ports_select_*]
    2516     array unset opts_array
    2517     # If no command (--set, --show, --list) is specified *but* more than one
    2518     # argument is specified, default to the set command.
     2518
     2519    # If no command (--set, --show, --list, --summary) is specified *but*
     2520    #  more than one argument is specified, default to the set command.
    25192521    if {[llength $commands] < 1 && [llength $portlist] > 1} {
    25202522        set command set
    25212523        ui_debug [concat "Although no command was specified, more than " \
     
    26012603                         "'$selected_version'."]
    26022604            return 0
    26032605        }
     2606        summary {
     2607            if {[llength $portlist] > 0} {
     2608                ui_warn [concat "The 'summary' command does not expect any " \
     2609                                "arguments. Extra arguments will be ignored."]
     2610            }
     2611
     2612            if {[catch {mportselect $command} portgroups]} {
     2613                ui_error "The 'summary' command failed: $portgroups"
     2614                return 1
     2615            }
     2616            puts "Portgroups\tOptions"
     2617            foreach pg $portgroups {
     2618                ui_notice $pg
     2619                if {[catch {mportselect list $pg} versions]} {
     2620                    ui_error "The list of versions could not be obtained: $versions"
     2621                    return 1
     2622                }
     2623                foreach v $versions {
     2624                    ui_notice -nonewline "\t"
     2625                        if {[catch {mportselect show $pg} selected_version]} {
     2626                            ui_error "The 'show' command failed: $selected_version"
     2627                            return 1
     2628                        }
     2629                    if {$selected_version == $v} {
     2630                        ui_msg "$v (active)"
     2631                    } else {
     2632                        ui_msg "$v"
     2633                    }
     2634                }
     2635            }
     2636            return 0
     2637        }
    26042638        default {
    26052639            ui_error "An unknown command '$command' was specified."
    26062640            return 1
     
    42944328    clean       {all archive dist work logs}
    42954329    mirror      {new}
    42964330    lint        {nitpick}
    4297     select      {list set show}
     4331    select      {list set show summary}
    42984332    log         {{phase 1} {level 1}}
    42994333    upgrade     {force enforce-variants no-replace no-rev-upgrade}
    43004334    rev-upgrade {id-loadcmd-check}