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_cli/src/driver.dart'; | 9 import 'package:analyzer_cli/src/driver.dart'; |
10 import 'package:args/args.dart'; | 10 import 'package:args/args.dart'; |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 } | 272 } |
273 } | 273 } |
274 | 274 |
275 static CommandLineOptions _parse(List<String> args) { | 275 static CommandLineOptions _parse(List<String> args) { |
276 // Check if the args are in a file (bazel worker mode). | 276 // Check if the args are in a file (bazel worker mode). |
277 if (args.last.startsWith('@')) { | 277 if (args.last.startsWith('@')) { |
278 var argsFile = new File(args.last.substring(1)); | 278 var argsFile = new File(args.last.substring(1)); |
279 args = argsFile.readAsLinesSync(); | 279 args = argsFile.readAsLinesSync(); |
280 } | 280 } |
281 | 281 |
| 282 bool verbose = args.contains('-v') || args.contains('--verbose'); |
| 283 bool hide = !verbose; |
| 284 |
282 args = args.expand((String arg) => arg.split('=')).toList(); | 285 args = args.expand((String arg) => arg.split('=')).toList(); |
283 var parser = new CommandLineParser() | 286 var parser = new CommandLineParser() |
284 ..addFlag('batch', | 287 ..addFlag('batch', |
285 abbr: 'b', | 288 abbr: 'b', |
286 help: 'Read commands from standard input (for testing).', | 289 help: 'Read commands from standard input (for testing).', |
287 defaultsTo: false, | 290 defaultsTo: false, |
288 negatable: false) | 291 negatable: false) |
289 ..addOption('dart-sdk', help: 'The path to the Dart SDK.') | 292 ..addOption('dart-sdk', help: 'The path to the Dart SDK.') |
290 ..addOption('dart-sdk-summary', | 293 ..addOption('dart-sdk-summary', |
291 help: 'The path to the Dart SDK summary file.', hide: true) | 294 help: 'The path to the Dart SDK summary file.', hide: true) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 defaultsTo: false, | 348 defaultsTo: false, |
346 negatable: false) | 349 negatable: false) |
347 ..addOption('x-package-warnings-prefix', | 350 ..addOption('x-package-warnings-prefix', |
348 help: | 351 help: |
349 'Show warnings from package: imports that match the given prefix', | 352 'Show warnings from package: imports that match the given prefix', |
350 hide: true) | 353 hide: true) |
351 ..addOption('x-perf-report', | 354 ..addOption('x-perf-report', |
352 help: 'Writes a performance report to the given file (experimental).') | 355 help: 'Writes a performance report to the given file (experimental).') |
353 ..addFlag('help', | 356 ..addFlag('help', |
354 abbr: 'h', | 357 abbr: 'h', |
355 help: 'Display this help message.', | 358 help: 'Display this help message.\n' |
| 359 'Add --verbose to show hidden options.', |
356 defaultsTo: false, | 360 defaultsTo: false, |
357 negatable: false) | 361 negatable: false) |
| 362 ..addFlag('verbose', |
| 363 abbr: 'v', defaultsTo: false, help: 'Verbose output.') |
358 ..addOption('url-mapping', | 364 ..addOption('url-mapping', |
359 help: '--url-mapping=libraryUri,/path/to/library.dart directs the ' | 365 help: '--url-mapping=libraryUri,/path/to/library.dart directs the ' |
360 'analyzer to use "library.dart" as the source for an import ' | 366 'analyzer to use "library.dart" as the source for an import ' |
361 'of "libraryUri".', | 367 'of "libraryUri".', |
362 allowMultiple: true, | 368 allowMultiple: true, |
363 splitCommas: false) | 369 splitCommas: false) |
364 // | 370 // |
365 // Build mode. | 371 // Build mode. |
366 // | 372 // |
367 ..addFlag('persistent_worker', | 373 ..addFlag('persistent_worker', |
368 help: 'Enable Bazel persistent worker mode.', | 374 help: 'Enable Bazel persistent worker mode.', |
369 defaultsTo: false, | 375 defaultsTo: false, |
370 negatable: false, | 376 negatable: false, |
371 hide: true) | 377 hide: hide) |
372 ..addOption('build-analysis-output', | 378 ..addOption('build-analysis-output', |
373 help: | 379 help: |
374 'Specifies the path to the file where analysis results should be w
ritten.', | 380 'Specifies the path to the file where analysis results should be w
ritten.', |
375 hide: true) | 381 hide: hide) |
376 ..addFlag('build-mode', | 382 ..addFlag('build-mode', |
377 // TODO(paulberry): add more documentation. | 383 // TODO(paulberry): add more documentation. |
378 help: 'Enable build mode.', | 384 help: 'Enable build mode.', |
379 defaultsTo: false, | 385 defaultsTo: false, |
380 negatable: false, | 386 negatable: false, |
381 hide: true) | 387 hide: hide) |
382 ..addOption('build-summary-input', | 388 ..addOption('build-summary-input', |
383 help: 'Path to a summary file that contains information from a ' | 389 help: 'Path to a summary file that contains information from a ' |
384 'previous analysis run. May be specified multiple times.', | 390 'previous analysis run. May be specified multiple times.', |
385 allowMultiple: true, | 391 allowMultiple: true, |
386 hide: true) | 392 hide: hide) |
387 ..addOption('build-summary-output', | 393 ..addOption('build-summary-output', |
388 help: 'Specifies the path to the file where the full summary ' | 394 help: 'Specifies the path to the file where the full summary ' |
389 'information should be written.', | 395 'information should be written.', |
390 hide: true) | 396 hide: hide) |
391 ..addOption('build-summary-output-semantic', | 397 ..addOption('build-summary-output-semantic', |
392 help: 'Specifies the path to the file where the semantic summary ' | 398 help: 'Specifies the path to the file where the semantic summary ' |
393 'information should be written.', | 399 'information should be written.', |
394 hide: true) | 400 hide: hide) |
395 ..addFlag('build-summary-only', | 401 ..addFlag('build-summary-only', |
396 help: 'Disable analysis (only generate summaries).', | 402 help: 'Disable analysis (only generate summaries).', |
397 defaultsTo: false, | 403 defaultsTo: false, |
398 negatable: false, | 404 negatable: false, |
399 hide: true) | 405 hide: hide) |
400 ..addFlag('build-summary-only-ast', | 406 ..addFlag('build-summary-only-ast', |
401 help: 'deprecated -- Generate summaries using ASTs.', | 407 help: 'deprecated -- Generate summaries using ASTs.', |
402 defaultsTo: false, | 408 defaultsTo: false, |
403 negatable: false, | 409 negatable: false, |
404 hide: true) | 410 hide: hide) |
405 ..addFlag('build-summary-only-diet', | 411 ..addFlag('build-summary-only-diet', |
406 help: 'Diet parse function bodies.', | 412 help: 'Diet parse function bodies.', |
407 defaultsTo: false, | 413 defaultsTo: false, |
408 negatable: false, | 414 negatable: false, |
409 hide: true) | 415 hide: hide) |
410 ..addFlag('build-summary-exclude-informative', | 416 ..addFlag('build-summary-exclude-informative', |
411 help: 'Exclude @informative information (docs, offsets, etc). ' | 417 help: 'Exclude @informative information (docs, offsets, etc). ' |
412 'Deprecated: please use --build-summary-output-semantic instead.', | 418 'Deprecated: please use --build-summary-output-semantic instead.', |
413 defaultsTo: false, | 419 defaultsTo: false, |
414 negatable: false, | 420 negatable: false, |
415 hide: true) | 421 hide: hide) |
416 ..addFlag('build-suppress-exit-code', | 422 ..addFlag('build-suppress-exit-code', |
417 help: 'Exit with code 0 even if errors are found.', | 423 help: 'Exit with code 0 even if errors are found.', |
418 defaultsTo: false, | 424 defaultsTo: false, |
419 negatable: false, | 425 negatable: false, |
420 hide: true) | 426 hide: hide) |
421 // | 427 // |
422 // Hidden flags. | 428 // Hidden flags. |
423 // | 429 // |
424 ..addFlag('enable-async', | 430 ..addFlag('enable-async', |
425 help: 'Enable support for the proposed async feature.', | 431 help: 'Enable support for the proposed async feature.', |
426 defaultsTo: false, | 432 defaultsTo: false, |
427 negatable: false, | 433 negatable: false, |
428 hide: true) | 434 hide: hide) |
429 ..addFlag('enable-enum', | 435 ..addFlag('enable-enum', |
430 help: 'Enable support for the proposed enum feature.', | 436 help: 'Enable support for the proposed enum feature.', |
431 defaultsTo: false, | 437 defaultsTo: false, |
432 negatable: false, | 438 negatable: false, |
433 hide: true) | 439 hide: hide) |
434 ..addFlag('enable-conditional-directives', | 440 ..addFlag('enable-conditional-directives', |
435 help: | 441 help: |
436 'deprecated -- Enable support for conditional directives (DEP 40).
', | 442 'deprecated -- Enable support for conditional directives (DEP 40).
', |
437 defaultsTo: false, | 443 defaultsTo: false, |
438 negatable: false, | 444 negatable: false, |
439 hide: true) | 445 hide: hide) |
440 ..addFlag('enable-null-aware-operators', | 446 ..addFlag('enable-null-aware-operators', |
441 help: 'Enable support for null-aware operators (DEP 9).', | 447 help: 'Enable support for null-aware operators (DEP 9).', |
442 defaultsTo: false, | 448 defaultsTo: false, |
443 negatable: false, | 449 negatable: false, |
444 hide: true) | 450 hide: hide) |
445 ..addFlag('enable-strict-call-checks', | 451 ..addFlag('enable-strict-call-checks', |
446 help: 'Fix issue 21938.', | 452 help: 'Fix issue 21938.', |
447 defaultsTo: false, | 453 defaultsTo: false, |
448 negatable: false, | 454 negatable: false, |
449 hide: true) | 455 hide: hide) |
450 ..addFlag('enable-new-task-model', | 456 ..addFlag('enable-new-task-model', |
451 help: 'deprecated -- Ennable new task model.', | 457 help: 'deprecated -- Ennable new task model.', |
452 defaultsTo: false, | 458 defaultsTo: false, |
453 negatable: false, | 459 negatable: false, |
454 hide: true) | 460 hide: hide) |
455 ..addFlag('initializing-formal-access', | 461 ..addFlag('initializing-formal-access', |
456 help: | 462 help: |
457 'Enable support for allowing access to field formal parameters in
a constructor\'s initializer list', | 463 'Enable support for allowing access to field formal parameters in
a constructor\'s initializer list', |
458 defaultsTo: false, | 464 defaultsTo: false, |
459 negatable: false, | 465 negatable: false, |
460 hide: true) | 466 hide: hide) |
461 ..addFlag('supermixin', | 467 ..addFlag('supermixin', |
462 help: 'Relax restrictions on mixins (DEP 34).', | 468 help: 'Relax restrictions on mixins (DEP 34).', |
463 defaultsTo: false, | 469 defaultsTo: false, |
464 negatable: false, | 470 negatable: false, |
465 hide: true) | 471 hide: hide) |
466 ..addFlag('log', | 472 ..addFlag('log', |
467 help: 'Log additional messages and exceptions.', | 473 help: 'Log additional messages and exceptions.', |
468 defaultsTo: false, | 474 defaultsTo: false, |
469 negatable: false, | 475 negatable: false, |
470 hide: true) | 476 hide: hide) |
471 ..addFlag('enable_type_checks', | 477 ..addFlag('enable_type_checks', |
472 help: 'Check types in constant evaluation.', | 478 help: 'Check types in constant evaluation.', |
473 defaultsTo: false, | 479 defaultsTo: false, |
474 negatable: false, | 480 negatable: false, |
475 hide: true) | 481 hide: hide) |
476 ..addFlag('strong', | 482 ..addFlag('strong', |
477 help: 'Enable strong static checks (https://goo.gl/DqcBsw)') | 483 help: 'Enable strong static checks (https://goo.gl/DqcBsw)') |
478 ..addFlag('no-implicit-casts', | 484 ..addFlag('no-implicit-casts', |
479 negatable: false, | 485 negatable: false, |
480 help: 'Disable implicit casts in strong mode (https://goo.gl/cTLz40)') | 486 help: 'Disable implicit casts in strong mode (https://goo.gl/cTLz40)') |
481 ..addFlag('no-implicit-dynamic', | 487 ..addFlag('no-implicit-dynamic', |
482 negatable: false, | 488 negatable: false, |
483 help: 'Disable implicit dynamic (https://goo.gl/m0UgXD)'); | 489 help: 'Disable implicit dynamic (https://goo.gl/m0UgXD)'); |
484 | 490 |
485 try { | 491 try { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 | 702 |
697 int _getNextFlagIndex(args, i) { | 703 int _getNextFlagIndex(args, i) { |
698 for (; i < args.length; ++i) { | 704 for (; i < args.length; ++i) { |
699 if (args[i].startsWith('--')) { | 705 if (args[i].startsWith('--')) { |
700 return i; | 706 return i; |
701 } | 707 } |
702 } | 708 } |
703 return i; | 709 return i; |
704 } | 710 } |
705 } | 711 } |
OLD | NEW |