Changeset 146694 for trunk/base


Ignore:
Timestamp:
Mar 15, 2016, 3:31:52 PM (4 years ago)
Author:
ijackson@…
Message:

Use ui_questions interactivity API in reclaim.

Instead of using ui_warn and gets for user confirmation,
use the ui_questions API to handle interactive mode in reclaim.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/macports1.0/reclaim.tcl

    r145639 r146694  
    382382
    383383            ui_msg "Found inactive ports: $inactive_names."
    384             ui_msg "Would you like to uninstall these ports? \[y/N\]: "
    385 
    386             set input [gets stdin]
    387             if {$input eq "Y" || $input eq "y" } {
    388 
    389                 ui_debug "Iterating through all inactive ports... again."
    390 
    391                 foreach port $inactive_ports {
    392                     set name [lindex $port 0]
    393 
    394                     # Get all dependents of the current port
    395                     if {[catch {set dependents [registry::list_dependents $name [lindex 1] [lindex 2] [lindex 3]]} error]} {
    396                         ui_error "something went wrong when trying to enumerate all dependents of $name"
    397                     }
    398                     if {${dependents} ne ""} {
    399                         ui_warn "Port $name is a dependent of $dependents. Do you want to uninstall this port at the risk of breaking other ports? \[Y/n\]"
    400 
    401                         set input [gets stdin]
    402                         if { $input eq "N" || "n" } {
    403                             ui_msg "Skipping port."
    404                             continue
     384            if {[info exists macports::ui_options(questions_multichoice)]} {
     385                set retstring [$macports::ui_options(questions_multichoice) "Would you like to uninstall these ports?" "" $inactive_names]
     386
     387                if {[llength $retstring] > 0} {
     388                    foreach i $retstring {
     389                        set port [lindex $inactive_ports $i]
     390                        set name [lindex $port 0]
     391
     392                        ui_msg "Uninstalling: $name"
     393
     394                        # Note: 'uninstall' takes a name, version, revision, variants and an options list.
     395                        if {[catch {registry_uninstall::uninstall $name [lindex $port 1] [lindex $port 2] [lindex $port 3] {}} error]} {
     396                            ui_error "something went wrong when uninstalling $name"
    405397                        }
    406398                    }
    407                     ui_msg "Uninstalling: $name"
    408 
    409                     # Note: 'uninstall' takes a name, version, revision, variants and an options list.
    410                     if {[catch {registry_uninstall::uninstall $name [lindex $port 1] [lindex $port 2] [lindex $port 3] {}} error]} {
    411                         ui_error "something went wrong when uninstalling $name"
    412                     }
    413                 }
    414             } else {
    415                 ui_msg "Not uninstalling ports."
     399                } else {
     400                    ui_msg "Not uninstalling ports."
     401                }
    416402            }
    417403        }
Note: See TracChangeset for help on using the changeset viewer.