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

Side by Side Diff: pkg/analysis_server/lib/driver.dart

Issue 239333006: Make the http portion of the analysis server optional. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library driver; 5 library driver;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:analysis_server/http_server.dart'; 9 import 'package:analysis_server/http_server.dart';
10 import 'package:analysis_server/src/socket_server.dart'; 10 import 'package:analysis_server/src/socket_server.dart';
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 "print this help message without starting a server", defaultsTo: false, 53 "print this help message without starting a server", defaultsTo: false,
54 negatable: false); 54 negatable: false);
55 parser.addOption(PORT_OPTION, help: 55 parser.addOption(PORT_OPTION, help:
56 "[port] the port on which the server will listen"); 56 "[port] the port on which the server will listen");
57 57
58 ArgResults results = parser.parse(args); 58 ArgResults results = parser.parse(args);
59 if (results[HELP_OPTION]) { 59 if (results[HELP_OPTION]) {
60 _printUsage(parser); 60 _printUsage(parser);
61 return; 61 return;
62 } 62 }
63 if (results[PORT_OPTION] == null) { 63 int port;
64 print('Missing required port number'); 64 bool serve_http = false;
65 print(''); 65 if (results[PORT_OPTION] != null) {
66 _printUsage(parser); 66 serve_http = true;
67 exitCode = 1; 67 try {
68 return; 68 port = int.parse(results[PORT_OPTION]);
69 } on FormatException {
70 print('Invalid port number: ${results[PORT_OPTION]}');
71 print('');
72 _printUsage(parser);
73 exitCode = 1;
74 return;
75 }
69 } 76 }
70 77
71 try { 78 if (serve_http) {
72 int port = int.parse(results[PORT_OPTION]);
73 httpServer.serveHttp(port); 79 httpServer.serveHttp(port);
74 } on FormatException {
75 print('Invalid port number: ${results[PORT_OPTION]}');
76 print('');
77 _printUsage(parser);
78 exitCode = 1;
79 return;
80 } 80 }
81 stdioServer.serveStdio().then((_) { 81 stdioServer.serveStdio().then((_) {
82 httpServer.close(); 82 if (serve_http) {
83 httpServer.close();
84 }
83 }); 85 });
84 } 86 }
85 87
86 /** 88 /**
87 * Print information about how to use the server. 89 * Print information about how to use the server.
88 */ 90 */
89 void _printUsage(ArgParser parser) { 91 void _printUsage(ArgParser parser) {
90 print('Usage: $BINARY_NAME [flags]'); 92 print('Usage: $BINARY_NAME [flags]');
91 print(''); 93 print('');
92 print('Supported flags are:'); 94 print('Supported flags are:');
93 print(parser.getUsage()); 95 print(parser.getUsage());
94 } 96 }
95 } 97 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698