Ticket #36179: base-select-summary.diff

File base-select-summary.diff, 5.1 KB (added by nerdling (Jeremy Lavergne), 11 years ago)

combine previous patches, fix bugs and whitespace

  • 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    # Error out if no group is specified or command is not --summary.
     2508    if {[llength $portlist] < 1 && [string map {ports_select_ ""} [lindex $commands 0]] != "summary"} {
     2509        ui_error "port select \[--list|--set|--show|--summary] \<group> \[<version>]"
    25102510        return 1
    25112511    }
    25122512    set group [lindex $portlist 0]
     
    25142514    array set opts_array $opts
    25152515    set commands [array names opts_array ports_select_*]
    25162516    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.
     2517   
     2518    # If no command (--set, --show, --list, --summary) is specified *but*
     2519    #  more than one argument is specified, default to the set command.
    25192520    if {[llength $commands] < 1 && [llength $portlist] > 1} {
    25202521        set command set
    25212522        ui_debug [concat "Although no command was specified, more than " \
     
    26012602                         "'$selected_version'."]
    26022603            return 0
    26032604        }
     2605        summary {
     2606            if {[llength $portlist] > 0} {
     2607                ui_warn [concat "The 'summary' command does not expect any " \
     2608                                "arguments. Extra arguments will be ignored."]
     2609            }
     2610
     2611            if {[catch {mportselect $command} portgroups]} {
     2612                ui_error "The 'summary' command failed: $portgroups"
     2613                return 1
     2614            }
     2615            puts "Portgroups\tOptions"
     2616            foreach pg $portgroups {
     2617                ui_notice $pg
     2618                if {[catch {mportselect list $pg} versions]} {
     2619                    ui_error "The list of versions could not be obtained: $versions"
     2620                    return 1
     2621                }
     2622                foreach v $versions {
     2623                    ui_notice -nonewline "\t"
     2624                        if {[catch {mportselect show $pg} selected_version]} {
     2625                            ui_error "The 'show' command failed: $selected_version"
     2626                            return 1
     2627                        }
     2628                    if {$selected_version == $v} {
     2629                        ui_msg "$v (active)"
     2630                    } else {
     2631                        ui_msg "$v"
     2632                    }
     2633                }
     2634                return 0
     2635            }
     2636        }
    26042637        default {
    26052638            ui_error "An unknown command '$command' was specified."
    26062639            return 1
     
    42944327    clean       {all archive dist work logs}
    42954328    mirror      {new}
    42964329    lint        {nitpick}
    4297     select      {list set show}
     4330    select      {list set show summary}
    42984331    log         {{phase 1} {level 1}}
    42994332    upgrade     {force enforce-variants no-replace no-rev-upgrade}
    43004333    rev-upgrade {id-loadcmd-check}