OLD | NEW |
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 library fasta.compiler_command_line; | 5 library fasta.compiler_command_line; |
6 | 6 |
7 import 'dart:io' show exit; | 7 import 'dart:io' show exit; |
8 | 8 |
9 import 'package:kernel/target/targets.dart' | 9 import 'package:kernel/target/targets.dart' |
10 show Target, getTarget, TargetFlags, targets; | 10 show Target, getTarget, TargetFlags, targets; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 String Function(Message, Severity) get formatWithoutLocation { | 149 String Function(Message, Severity) get formatWithoutLocation { |
150 return options["formatWithoutLocation"] ?? | 150 return options["formatWithoutLocation"] ?? |
151 command_line_reporting.formatWithoutLocation; | 151 command_line_reporting.formatWithoutLocation; |
152 } | 152 } |
153 | 153 |
154 static dynamic withGlobalOptions(String programName, List<String> arguments, | 154 static dynamic withGlobalOptions(String programName, List<String> arguments, |
155 dynamic f(CompilerContext context)) { | 155 dynamic f(CompilerContext context)) { |
156 return CompilerContext.withGlobalOptions( | 156 return CompilerContext.withGlobalOptions( |
157 new CompilerCommandLine(programName, arguments), f); | 157 new CompilerCommandLine(programName, arguments), f); |
158 } | 158 } |
159 | |
160 static CompilerCommandLine forRootContext() { | |
161 return new CompilerCommandLine("", [""]); | |
162 } | |
163 } | 159 } |
164 | 160 |
165 Message computeUsage(String programName, bool verbose) { | 161 Message computeUsage(String programName, bool verbose) { |
166 String basicUsage = "Usage: $programName [options] dartfile\n"; | 162 String basicUsage = "Usage: $programName [options] dartfile\n"; |
167 String summary; | 163 String summary; |
168 String options = | 164 String options = |
169 (verbose ? messageFastaUsageLong.message : messageFastaUsageShort.message) | 165 (verbose ? messageFastaUsageLong.message : messageFastaUsageShort.message) |
170 .trim(); | 166 .trim(); |
171 switch (programName) { | 167 switch (programName) { |
172 case "outline": | 168 case "outline": |
(...skipping 17 matching lines...) Expand all Loading... |
190 StringBuffer sb = new StringBuffer(basicUsage); | 186 StringBuffer sb = new StringBuffer(basicUsage); |
191 if (summary != null) { | 187 if (summary != null) { |
192 sb.writeln(); | 188 sb.writeln(); |
193 sb.writeln(summary); | 189 sb.writeln(summary); |
194 sb.writeln(); | 190 sb.writeln(); |
195 } | 191 } |
196 sb.write(options); | 192 sb.write(options); |
197 // TODO(ahe): Don't use [templateUnspecified]. | 193 // TODO(ahe): Don't use [templateUnspecified]. |
198 return templateUnspecified.withArguments("$sb"); | 194 return templateUnspecified.withArguments("$sb"); |
199 } | 195 } |
OLD | NEW |