[120834] branches/gsoc14-interactive/base/src/port/port.tcl
shasha at macports.org
shasha at macports.org
Mon Jun 9 03:01:00 PDT 2014
Revision: 120834
https://trac.macports.org/changeset/120834
Author: shasha at macports.org
Date: 2014-06-09 03:01:00 -0700 (Mon, 09 Jun 2014)
Log Message:
-----------
proc for yesno question type added
Modified Paths:
--------------
branches/gsoc14-interactive/base/src/port/port.tcl
Modified: branches/gsoc14-interactive/base/src/port/port.tcl
===================================================================
--- branches/gsoc14-interactive/base/src/port/port.tcl 2014-06-09 09:59:17 UTC (rev 120833)
+++ branches/gsoc14-interactive/base/src/port/port.tcl 2014-06-09 10:01:00 UTC (rev 120834)
@@ -5228,6 +5228,62 @@
}
}
+# Create namespace for questions
+namespace eval portclient::questions {
+ ##
+ # Display a question that asks the user for yes/no as an answer.
+ #
+ # @param msg
+ # The question specific message that is to be printed before asking the question.
+ # @param name
+ # The name of the port.
+ # @param ports
+ # The port/list of ports for which the question is being asked.
+ # @param def
+ # The default answer to the question.
+ # @param time
+ # The amount of time for which a timeout is to occur.
+ proc ui_ask_yesno {msg name ports def time} {
+ # Check if timeout is set or not
+ if {$time > 0} {
+ # Run ui_timeout and skip the rest of the stuff here
+ puts "just testing"
+ }
+
+ puts -nonewline $msg
+ set leftmargin "\t"
+
+ # Print portname or port list suitably
+ if {llength ports == 1} {
+ puts " "
+ puts $ports
+ } else {
+ foreach port $ports {
+ puts -nonewline $leftmargin
+ puts $port
+ }
+ }
+
+ # Check for the default and print accordingly
+ if {$def == {y}} {
+ puts -nonewline "Continue? \[Y/n\]: "
+ } else {
+ puts -nonewline "Continue? \[y/N\]: "
+ }
+
+ # User input (probably requires some input error checking code)
+ while 1 {
+ set input [gets stdin]
+ if {$input in {y Y}} {
+ return 0
+ } elseif {$input in {n N}} {
+ return 1
+ } else {
+ puts "Please enter either 'y' or 'n'."
+ }
+ }
+ }
+}
##########################################
# Main
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140609/93f80628/attachment.html>
More information about the macports-changes
mailing list