Chromium Code Reviews| Index: pkg/docgen/bin/docgen.dart |
| diff --git a/pkg/docgen/bin/docgen.dart b/pkg/docgen/bin/docgen.dart |
| index 2a116de5b1bec5557663576bbb3959b1757c1734..db9e15d2c46d55e0b8cd4dcf2466808b8fc95473 100644 |
| --- a/pkg/docgen/bin/docgen.dart |
| +++ b/pkg/docgen/bin/docgen.dart |
| @@ -12,17 +12,21 @@ import 'package:path/path.dart' as path; |
| List<String> excludedLibraries = []; |
| +ArgParser argParser = _initArgParser(); |
|
Emily Fortuna
2014/02/04 20:40:03
why move this out as a global variable? I'd be mo
Alan Knight
2014/02/04 20:48:07
It seemed wasteful to create one, throw it away, a
|
| + |
| /** |
| * Analyzes Dart files and generates a representation of included libraries, |
| * classes, and members. |
| */ |
| void main(List<String> arguments) { |
| - var results = _initArgParser().parse(arguments); |
| + var results = argParser.parse(arguments); |
| var includeSdk = results['parse-sdk'] || results['include-sdk']; |
| var scriptDir = path.dirname(Platform.script.toFilePath()); |
| var introduction = includeSdk ? '' : results['introduction']; |
| - docgen(results.rest.map(path.normalize).toList(), |
| + var files = results.rest.map(path.normalize).toList(); |
| + if (files.isEmpty) printHelpAndExit(); |
| + docgen(files, |
| packageRoot: results['package-root'], |
| outputToYaml: !results['json'], |
| includePrivate: results['include-private'], |
| @@ -36,6 +40,15 @@ void main(List<String> arguments) { |
| } |
| /** |
| + * Print help if we are passed the help option or invalid arguments. |
| + */ |
| +void printHelpAndExit() { |
|
Emily Fortuna
2014/02/04 20:40:03
should probably make this private, yes?
Alan Knight
2014/02/04 20:48:07
Sure. I don't really know under what circumstances
|
| + print(argParser.getUsage()); |
| + print('Usage: dart docgen.dart [OPTIONS] fooDir/barFile'); |
| + exit(0); |
| +} |
| + |
| +/** |
| * Creates parser for docgen command line arguments. |
| */ |
| ArgParser _initArgParser() { |
| @@ -44,11 +57,7 @@ ArgParser _initArgParser() { |
| help: 'Prints help and usage information.', |
| negatable: false, |
| callback: (help) { |
| - if (help) { |
| - print(parser.getUsage()); |
| - print('Usage: dart docgen.dart [OPTIONS] fooDir/barFile'); |
| - exit(0); |
| - } |
| + if (help) printHelpAndExit(); |
| }); |
| parser.addFlag('verbose', abbr: 'v', |
| help: 'Output more logging information.', negatable: false, |