Changeset 117702


Ignore:
Timestamp:
Mar 8, 2014, 5:24:15 PM (7 years ago)
Author:
cal@…
Message:

port select --summary: format all lines equally, sort the "none" option to the back

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port/port.tcl

    r117617 r117702  
    26152615            set w2 8
    26162616            set formatStr "%-*s  %-*s  %s"
    2617             puts [format $formatStr $w1 "Name" $w2 "Selected" "Options"]
     2617
     2618            set groups [list]
    26182619            foreach pg $portgroups {
     2620                array set groupdesc {}
     2621                set groupdesc(name) [string trim $pg]
     2622
    26192623                if {[catch {mportselect list $pg} versions]} {
    2620                     ui_error "The list of versions could not be obtained: $versions"
    2621                     return 1
    2622                 }
    2623 
    2624                 foreach v $versions {
    2625                     if {[catch {mportselect show $pg} selected_version]} {
    2626                         ui_error "The 'show' command failed: $selected_version"
    2627                         return 1
    2628                     }
    2629                 }
     2624                    ui_warn "The list of options for the select group $pg could not be obtained: $versions"
     2625                    continue
     2626                }
     2627                # remove "none", sort the list, append none at the end
     2628                set noneidx [lsearch -exact $versions "none"]
     2629                set versions [lsort [lreplace $versions $noneidx $noneidx]]
     2630                lappend versions "none"
     2631                set groupdesc(versions) $versions
     2632
     2633                if {[catch {mportselect show $pg} selected_version]} {
     2634                    ui_warn "The currently selected option for the select group $pg could not be obtained: $selected_version"
     2635                    continue
     2636                }
     2637                set groupdesc(selected) $selected_version
    26302638
    26312639                set w1 [expr {max($w1, [string length $pg])}]
    26322640                set w2 [expr {max($w2, [string length $selected_version])}]
    26332641
    2634                 puts [format $formatStr $w1 [string trim $pg] $w2 $selected_version [join $versions " "]]
     2642                lappend groups [array get groupdesc]
     2643                array unset groupdesc
     2644            }
     2645            puts [format $formatStr $w1 "Name" $w2 "Selected" "Options"]
     2646            puts [format $formatStr $w1 "====" $w2 "========" "======="]
     2647            foreach groupdesc $groups {
     2648                array set groupd $groupdesc
     2649                puts [format $formatStr $w1 $groupd(name) $w2 $groupd(selected) [join $groupd(versions) " "]]
     2650                array unset groupd
    26352651            }
    26362652            return 0
Note: See TracChangeset for help on using the changeset viewer.