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

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

pick up raim's version 3 changes

  • 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
     2617            set w1 5
     2618            set w2 10
     2619            set w3 15
     2620            set formatStr "%-*s  %-*s  %-*s"
     2621            puts [format $formatStr $w1 "Name" $w2 "Selected" $w3 "Options"]
     2622            foreach pg $portgroups {
     2623                if {[catch {mportselect list $pg} versions]} {
     2624                    ui_error "The list of versions could not be obtained: $versions"
     2625                    return 1
     2626                }
     2627                foreach v $versions {
     2628                    if {[catch {mportselect show $pg} selected_version]} {
     2629                        ui_error "The 'show' command failed: $selected_version"
     2630                        return 1
     2631                    }
     2632                }
     2633                # TODO: format output
     2634                # portgroup | active | options options options
     2635                puts [format $formatStr $w1 [string trim $pg] $w2 $selected_version $w3 [join $versions " "]]
     2636            }
     2637            return 0
     2638        }
    26042639        default {
    26052640            ui_error "An unknown command '$command' was specified."
    26062641            return 1
     
    42944329    clean       {all archive dist work logs}
    42954330    mirror      {new}
    42964331    lint        {nitpick}
    4297     select      {list set show}
     4332    select      {list set show summary}
    42984333    log         {{phase 1} {level 1}}
    42994334    upgrade     {force enforce-variants no-replace no-rev-upgrade}
    43004335    rev-upgrade {id-loadcmd-check}