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

Unified Diff: sdk/lib/_internal/pub/lib/src/command/serve.dart

Issue 204983022: Add a hidden flag for specifying pub serve's admin port. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/command.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/command/serve.dart
diff --git a/sdk/lib/_internal/pub/lib/src/command/serve.dart b/sdk/lib/_internal/pub/lib/src/command/serve.dart
index 614436f71b3bb2b59418da5b122ee12acafee24d..f7c140a778f7d45b40f6ae85490627ec882459c9 100644
--- a/sdk/lib/_internal/pub/lib/src/command/serve.dart
+++ b/sdk/lib/_internal/pub/lib/src/command/serve.dart
@@ -13,7 +13,6 @@ import 'package:path/path.dart' as p;
import '../barback/build_environment.dart';
import '../barback/pub_package_provider.dart';
import '../command.dart';
-import '../exit_codes.dart' as exit_codes;
import '../io.dart';
import '../log.dart' as log;
import '../utils.dart';
@@ -33,6 +32,19 @@ class ServeCommand extends PubCommand {
String get hostname => commandOptions['hostname'];
+ /// The base port for the servers.
+ ///
+ /// This will print a usage error and exit if the specified port is invalid.
+ int get port => parseInt(commandOptions['port'], 'port');
+
+ /// The port for the admin UI.
+ ///
+ /// This will print a usage error and exit if the specified port is invalid.
+ int get adminPort {
+ var adminPort = commandOptions['admin-port'];
+ return adminPort == null ? null : parseInt(adminPort, 'admin port');
+ }
+
/// `true` if Dart entrypoints should be compiled to JavaScript.
bool get useDart2JS => commandOptions['dart2js'];
@@ -59,6 +71,9 @@ class ServeCommand extends PubCommand {
// Remove this (and always log) when #16954 is fixed.
commandParser.addFlag('log-admin-url', defaultsTo: false, hide: true);
+ // TODO(nweiz): Make this public when issue 16954 is fixed.
+ commandParser.addOption('admin-port', hide: true);
+
commandParser.addFlag('dart2js', defaultsTo: true,
help: 'Compile Dart to JavaScript.');
commandParser.addFlag('force-poll', defaultsTo: false,
@@ -68,14 +83,9 @@ class ServeCommand extends PubCommand {
}
Future onRun() {
- var port;
- try {
- port = int.parse(commandOptions['port']);
- } on FormatException catch (_) {
- log.error('Could not parse port "${commandOptions['port']}"');
- this.printUsage();
- return flushThenExit(exit_codes.USAGE);
- }
+ var port = parseInt(commandOptions['port'], 'port');
+ var adminPort = commandOptions['admin-port'] == null ? null :
+ parseInt(commandOptions['admin-port'], 'admin port');
var directories = _parseDirectoriesToServe();
@@ -88,7 +98,7 @@ class ServeCommand extends PubCommand {
var directoryLength = directories.map((dir) => dir.length)
.reduce(math.max);
- return environment.startAdminServer().then((server) {
+ return environment.startAdminServer(adminPort).then((server) {
server.results.listen((_) {
// The admin server produces no result values.
assert(false);
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/command.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698