Chromium Code Reviews| Index: utils/pub/io.dart |
| diff --git a/utils/pub/io.dart b/utils/pub/io.dart |
| index 0ecc7b2498942789d4dbbabfa8db420dec1a3bdb..00a4421748b392826fa7425d97602b138e8ab6bf 100644 |
| --- a/utils/pub/io.dart |
| +++ b/utils/pub/io.dart |
| @@ -469,6 +469,15 @@ String relativeToPub(String target) { |
| /// A StringInputStream reading from stdin. |
| final _stringStdin = new StringInputStream(stdin); |
| +/// Displays a message and reads a yes/no confirmation from the user. Returns |
| +/// a [Future] that completes to `true` if the user confirms or `false` if they |
| +/// do not. |
|
nweiz
2012/12/12 21:21:21
It would be nice to document that the message shou
Bob Nystrom
2012/12/12 21:45:36
Done.
|
| +Future<bool> confirm(String message) { |
| + log.fine('Showing confirm message: $message'); |
| + stdout.writeString("$message (y/n)? "); |
| + return readLine().transform((line) => new RegExp(r"^[yY]").hasMatch(line)); |
| +} |
| + |
| /// Returns a single line read from a [StringInputStream]. By default, reads |
| /// from stdin. |
| /// |
| @@ -498,7 +507,9 @@ Future<String> readLine([StringInputStream stream]) { |
| stream.onLine = () { |
| removeCallbacks(); |
| - completer.complete(stream.readLine()); |
| + var line = stream.readLine(); |
| + log.io('Read line: $line'); |
| + completer.complete(line); |
| }; |
| stream.onError = (e) { |
| @@ -952,7 +963,7 @@ Future<bool> _extractTarGzWindows(InputStream stream, String destination) { |
| InputStream createTarGz(List contents, {baseDir}) { |
| var buffer = new StringBuffer(); |
| buffer.add('Creating .tag.gz stream containing:\n'); |
| - contents.forEach(buffer.add); |
| + contents.forEach((file) => buffer.add('$file\n')); |
| log.fine(buffer.toString()); |
| // TODO(nweiz): Propagate errors to the returned stream (including non-zero |