Skip to content

Commit

Permalink
registry2.0: Simplify port formatting for question
Browse files Browse the repository at this point in the history
Simplify the formatting of port strings that are passed to the procs
given in $ui_options(questions_*choice), or in the non-interactive case,
are printed with ui_msg.
  • Loading branch information
raimue committed Feb 7, 2017
1 parent 01d98db commit 014e51f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 31 deletions.
24 changes: 7 additions & 17 deletions src/registry2.0/portimage.tcl
Expand Up @@ -228,25 +228,15 @@ proc _check_registry {name version revision variants} {
ui_msg "$UI_PREFIX [msgcat::mc $msg]"
}
foreach i $ilist {
set iname [$i name]
set iversion [$i version]
set irevision [$i revision]
set ivariants [$i variants]
##
# User Interaction Question
# Asking choice to select option in case of ambiguous activate
set portstr [format "%s @%s_%s%s" [$i name] [$i version] [$i revision] [$i variants]]
if {[$i state] eq "installed"} {
append portstr [msgcat::mc " (active)"]
}

if {[info exists macports::ui_options(questions_singlechoice)]} {
if { [$i state] eq "installed" } {
lappend portilist "$iname @${iversion}_${irevision}${ivariants} (active)"
} else {
lappend portilist "$iname @${iversion}_${irevision}${ivariants}"
}
lappend portilist "$portstr"
} else {
if { [$i state] eq "installed" } {
ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s_%s%s (active)"] $iname $iversion $irevision $ivariants]"
} else {
ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s_%s%s"] $iname $iversion $irevision $ivariants]"
}
ui_msg "$UI_PREFIX $portstr"
}
}
if {[info exists macports::ui_options(questions_singlechoice)]} {
Expand Down
21 changes: 7 additions & 14 deletions src/registry2.0/portuninstall.tcl
Expand Up @@ -151,22 +151,15 @@ proc uninstall {portname {version ""} {revision ""} {variants 0} {optionslist ""
}
set sortedlist [portlist_sortint $ilist]
foreach i $sortedlist {
set ispec "[$i version]_[$i revision][$i variants]"
##
# User Interaction Question
# Asking choice to select option in case of ambiguous uninstall
set portstr [format "%s @%s_%s%s" [$i name] [$i version] [$i revision] [$i variants]]
if {[$i state] eq "installed"} {
append portstr [msgcat::mc " (active)"]
}

if {[info exists macports::ui_options(questions_multichoice)]} {
if { [$i state] eq "installed" } {
lappend portilist "[$i name] @[$i version]_[$i revision][$i variants] (active)"
} else {
lappend portilist "[$i name] @[$i version]_[$i revision][$i variants]"
}
lappend portilist "$portstr"
} else {
if {[$i state] eq "installed"} {
ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s (active)"] [$i name] $ispec]"
} else {
ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s"] [$i name] $ispec]"
}
ui_msg "$UI_PREFIX $portstr"
}
}
if {[info exists macports::ui_options(questions_multichoice)]} {
Expand Down

0 comments on commit 014e51f

Please sign in to comment.