Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15387977
D16927.id40748.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D16927.id40748.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -491,6 +491,7 @@
'phutil_console_get_terminal_width' => 'console/format.php',
'phutil_console_prompt' => 'console/format.php',
'phutil_console_require_tty' => 'console/format.php',
+ 'phutil_console_select' => 'console/format.php',
'phutil_console_wrap' => 'console/format.php',
'phutil_count' => 'internationalization/pht.php',
'phutil_date_format' => 'utils/viewutils.php',
diff --git a/src/console/format.php b/src/console/format.php
--- a/src/console/format.php
+++ b/src/console/format.php
@@ -24,6 +24,20 @@
}
}
+function phutil_console_select($prompt, $min, $max) {
+ $select_options = '['.$min.' - '.$max.']';
+ do {
+ $response = phutil_console_prompt($prompt.' '.$select_options);
+ $selection = trim($response);
+
+ if (preg_match('/^\d+\z/', $selection)) {
+ $selection = (int)$selection;
+ if ($selection >= $min && $selection <= $max) {
+ return $selection;
+ }
+ }
+ } while (true);
+}
function phutil_console_prompt($prompt, $history = '') {
echo "\n\n";
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 16, 3:10 AM (6 d, 16 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7705413
Default Alt Text
D16927.id40748.diff (1 KB)
Attached To
Mode
D16927: Add a console method for picking from a list of options
Attached
Detach File
Event Timeline
Log In to Comment