Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Side by Side Diff: utils/pub/io.dart

Issue 12282038: Remove deprecated string features. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Helper functionality to make working with IO easier. 5 /// Helper functionality to make working with IO easier.
6 library io; 6 library io;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:isolate'; 10 import 'dart:isolate';
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 streamToLines(wrapInputStream(stdin).toStringStream()); 358 streamToLines(wrapInputStream(stdin).toStringStream());
359 359
360 /// Displays a message and reads a yes/no confirmation from the user. Returns 360 /// Displays a message and reads a yes/no confirmation from the user. Returns
361 /// a [Future] that completes to `true` if the user confirms or `false` if they 361 /// a [Future] that completes to `true` if the user confirms or `false` if they
362 /// do not. 362 /// do not.
363 /// 363 ///
364 /// This will automatically append " (y/n)?" to the message, so [message] 364 /// This will automatically append " (y/n)?" to the message, so [message]
365 /// should just be a fragment like, "Are you sure you want to proceed". 365 /// should just be a fragment like, "Are you sure you want to proceed".
366 Future<bool> confirm(String message) { 366 Future<bool> confirm(String message) {
367 log.fine('Showing confirm message: $message'); 367 log.fine('Showing confirm message: $message');
368 stdoutSink.add("$message (y/n)? ".charCodes); 368 stdoutSink.add("$message (y/n)? ".codeUnits);
369 return streamFirst(stdinLines) 369 return streamFirst(stdinLines)
370 .then((line) => new RegExp(r"^[yY]").hasMatch(line)); 370 .then((line) => new RegExp(r"^[yY]").hasMatch(line));
371 } 371 }
372 372
373 /// Reads and discards all output from [inputStream]. Returns a [Future] that 373 /// Reads and discards all output from [inputStream]. Returns a [Future] that
374 /// completes when the stream is closed. 374 /// completes when the stream is closed.
375 Future drainInputStream(InputStream inputStream) { 375 Future drainInputStream(InputStream inputStream) {
376 var completer = new Completer(); 376 var completer = new Completer();
377 if (inputStream.closed) { 377 if (inputStream.closed) {
378 completer.complete(); 378 completer.complete();
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 const PubProcessResult(this.stdout, this.stderr, this.exitCode); 860 const PubProcessResult(this.stdout, this.stderr, this.exitCode);
861 861
862 bool get success => exitCode == 0; 862 bool get success => exitCode == 0;
863 } 863 }
864 864
865 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. 865 /// Gets a [Uri] for [uri], which can either already be one, or be a [String].
866 Uri _getUri(uri) { 866 Uri _getUri(uri) {
867 if (uri is Uri) return uri; 867 if (uri is Uri) return uri;
868 return Uri.parse(uri); 868 return Uri.parse(uri);
869 } 869 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698