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

Side by Side Diff: lib/src/compiler/command.dart

Issue 2113203002: Print usage when no source files are passed (Closed) Base URL: https://github.com/dart-lang/dev_compiler@master
Patch Set: Created 4 years, 5 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
« 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'dart:convert' show JSON; 5 import 'dart:convert' show JSON;
6 import 'dart:io'; 6 import 'dart:io';
7 import 'package:args/command_runner.dart'; 7 import 'package:args/command_runner.dart';
8 import 'package:analyzer/src/generated/source.dart' show Source; 8 import 'package:analyzer/src/generated/source.dart' show Source;
9 import 'package:analyzer/src/summary/package_bundle_reader.dart' 9 import 'package:analyzer/src/summary/package_bundle_reader.dart'
10 show InSummarySource; 10 show InSummarySource;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 usageException('Output file $outPath must be within the module root ' 60 usageException('Output file $outPath must be within the module root '
61 'directory $moduleRoot'); 61 'directory $moduleRoot');
62 } 62 }
63 modulePath = 63 modulePath =
64 path.withoutExtension(path.relative(outPath, from: moduleRoot)); 64 path.withoutExtension(path.relative(outPath, from: moduleRoot));
65 } else { 65 } else {
66 moduleRoot = path.dirname(outPath); 66 moduleRoot = path.dirname(outPath);
67 modulePath = path.basenameWithoutExtension(outPath); 67 modulePath = path.basenameWithoutExtension(outPath);
68 } 68 }
69 69
70 if (argResults.rest.isEmpty) {
71 usageException('Please pass at least one source file as an argument.');
72 }
73
70 var unit = new BuildUnit(modulePath, buildRoot, argResults.rest, 74 var unit = new BuildUnit(modulePath, buildRoot, argResults.rest,
71 (source) => _moduleForLibrary(moduleRoot, source)); 75 (source) => _moduleForLibrary(moduleRoot, source));
72 76
73 JSModuleFile module = compiler.compile(unit, compilerOptions); 77 JSModuleFile module = compiler.compile(unit, compilerOptions);
74 module.errors.forEach(messageHandler); 78 module.errors.forEach(messageHandler);
75 79
76 if (!module.isValid) throw new CompileErrorException(); 80 if (!module.isValid) throw new CompileErrorException();
77 81
78 // Write JS file, as well as source map and summary (if requested). 82 // Write JS file, as well as source map and summary (if requested).
79 new File(outPath).writeAsStringSync(module.code); 83 new File(outPath).writeAsStringSync(module.code);
(...skipping 25 matching lines...) Expand all
105 'Imported file "${source.uri}" was not found as a summary or source ' 109 'Imported file "${source.uri}" was not found as a summary or source '
106 'file. Please pass in either the summary or the source file ' 110 'file. Please pass in either the summary or the source file '
107 'for this import.'); 111 'for this import.');
108 } 112 }
109 } 113 }
110 114
111 /// Thrown when the input source code has errors. 115 /// Thrown when the input source code has errors.
112 class CompileErrorException implements Exception { 116 class CompileErrorException implements Exception {
113 toString() => '\nPlease fix all errors before compiling (warnings are okay).'; 117 toString() => '\nPlease fix all errors before compiling (warnings are okay).';
114 } 118 }
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