OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 analyzer_cli.src.options; | 5 library analyzer_cli.src.options; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:analyzer/file_system/physical_file_system.dart'; | 9 import 'package:analyzer/file_system/physical_file_system.dart'; |
10 import 'package:analyzer/src/command_line/arguments.dart'; | 10 import 'package:analyzer/src/command_line/arguments.dart'; |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 hide: hide); | 449 hide: hide); |
450 | 450 |
451 try { | 451 try { |
452 if (args.contains('--$ignoreUnrecognizedFlagsFlag')) { | 452 if (args.contains('--$ignoreUnrecognizedFlagsFlag')) { |
453 args = filterUnknownArguments(args, parser); | 453 args = filterUnknownArguments(args, parser); |
454 } | 454 } |
455 ArgResults results = parser.parse(args); | 455 ArgResults results = parser.parse(args); |
456 | 456 |
457 // Persistent worker. | 457 // Persistent worker. |
458 if (args.contains('--persistent_worker')) { | 458 if (args.contains('--persistent_worker')) { |
459 bool validArgs; | 459 bool hasBuildMode = args.contains('--build-mode'); |
460 if (!args.contains('--build-mode')) { | 460 bool onlyDartSdkArg = args.length == 2 || |
461 validArgs = false; | 461 (args.length == 3 && args.any((a) => a.startsWith('--dart-sdk'))) || |
462 } else if (args.length == 2) { | 462 (args.length == 4 && args.contains('--dart-sdk')); |
463 validArgs = true; | 463 if (!(hasBuildMode && onlyDartSdkArg)) { |
464 } else if (args.length == 4 && args.contains('--dart-sdk')) { | |
465 validArgs = true; | |
466 } else { | |
467 validArgs = false; | |
468 } | |
469 if (!validArgs) { | |
470 printAndFail('The --persistent_worker flag should be used with and ' | 464 printAndFail('The --persistent_worker flag should be used with and ' |
471 'only with the --build-mode flag, and possibly the --dart-sdk ' | 465 'only with the --build-mode flag, and possibly the --dart-sdk ' |
472 'option. Got: $args'); | 466 'option. Got: $args'); |
473 return null; // Only reachable in testing. | 467 return null; // Only reachable in testing. |
474 } | 468 } |
475 return new CommandLineOptions._fromArgs(results); | 469 return new CommandLineOptions._fromArgs(results); |
476 } | 470 } |
477 | 471 |
478 // Help requests. | 472 // Help requests. |
479 if (results['help']) { | 473 if (results['help']) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 'Usage: $_binaryName [options...] <directory or list of files>'); | 516 'Usage: $_binaryName [options...] <directory or list of files>'); |
523 errorSink.writeln(''); | 517 errorSink.writeln(''); |
524 errorSink.writeln(parser.usage); | 518 errorSink.writeln(parser.usage); |
525 errorSink.writeln(''); | 519 errorSink.writeln(''); |
526 errorSink.writeln(''' | 520 errorSink.writeln(''' |
527 Run "dartanalyzer -h -v" for verbose help output, including less commonly used o
ptions. | 521 Run "dartanalyzer -h -v" for verbose help output, including less commonly used o
ptions. |
528 For more information, see http://www.dartlang.org/tools/analyzer. | 522 For more information, see http://www.dartlang.org/tools/analyzer. |
529 '''); | 523 '''); |
530 } | 524 } |
531 } | 525 } |
OLD | NEW |