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

Side by Side Diff: pkg/analysis_server/bin/dartdeps.dart

Issue 175173002: first cut cmdline analysis server launcher (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:async';
6 import 'dart:io';
7
8 import 'package:args/args.dart';
9 import 'package:analysis_server/src/analysis_manager.dart';
10
11 /**
12 * Start analysis server as a separate process and use the websocket protocol
13 * to analyze the application specified on the command line.
14 */
15 void main(List<String> args) {
16 _DartDependencyAnalyzer analyzer = new _DartDependencyAnalyzer();
17 analyzer.start(args);
18 }
19
20 /**
21 * Instances of [_DartDependencyAnalyzer] launch an analysis server and use
22 * that server to analyze the dependencies of an application.
23 */
24 class _DartDependencyAnalyzer {
Brian Wilkerson 2014/02/21 15:09:54 Style question: In analysis server I put the priva
danrubel 2014/02/21 15:51:13 I made it private and kept it in this library beca
25 /**
26 * The name of the application that is used to start the analyzer.
27 */
28 static const BINARY_NAME = 'dartdeps';
Brian Wilkerson 2014/02/21 15:09:54 I thought I remembered that the application was go
danrubel 2014/02/21 15:51:13 I like "dartdeps" because this is more the just sh
29
30 /**
31 * The name of the option used to print usage information.
32 */
33 static const String HELP_OPTION = "help";
34
35 /**
36 * Parse the command line arguments to determine the application to be
37 * analyzed, then launch and manage an analysis server to do the work.
38 * If there is a problem with the given arguments, then return a non zero
39 * value, otherwise return zero.
40 */
41 void start(List<String> args) {
42 var parser = new ArgParser();
43 parser.addFlag(HELP_OPTION, help:
44 "print this help message without starting analysis", defaultsTo: false,
45 negatable: false);
46
47 // Parse arguments
48 ArgResults results = parser.parse(args);
49 if (results[HELP_OPTION]) {
50 _printUsage(parser);
51 return;
52 }
53 if (results.rest.length == 0) {
54 _printUsage(parser);
55 exitCode = 1;
56 return;
57 }
58 Directory appDir = new Directory(results.rest[0]);
59 if (!appDir.existsSync()) {
60 print('Specified application directory does not exist: $appDir');
61 print('');
62 _printUsage(parser);
63 exitCode = 1;
64 return;
65 }
66 if (results.rest.length > 1) {
67 print('Unexpected arguments after $appDir');
68 print('');
69 _printUsage(parser);
70 exitCode = 1;
71 return;
72 }
73
74 // Assume that the analysis server entry point is in the same directory
75 StringBuffer path = new StringBuffer();
76 path.write(FileSystemEntity.parentOf(Platform.script.toFilePath()));
77 path.write(Platform.pathSeparator);
78 path.write("server.dart");
79
80 // Launch analysis server
81 AnalysisManager.start(path.toString()).then(_analyze);
82 }
83
84 void _analyze(AnalysisManager mgr) {
Brian Wilkerson 2014/02/21 15:09:54 Style question: Is there any value in marking an i
danrubel 2014/02/21 15:51:13 Good point! Removed _
85 print("Analyzing...");
86 new Timer(new Duration(seconds: 5), () {
87 if (mgr.stop()) {
88 print("stopped");
89 } else {
90 print("already stopped");
91 }
92 });
93 }
94
95 /**
96 * Print information about how to use the server.
97 */
98 void _printUsage(ArgParser parser) {
99 print('Usage: $BINARY_NAME [flags] <application_directory>');
100 print('');
101 print('Supported flags are:');
102 print(parser.getUsage());
103 }
104 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/analysis_manager.dart » ('j') | pkg/analysis_server/lib/src/analysis_manager.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698