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

Side by Side Diff: pkg/polymer/bin/new_entry.dart

Issue 492303002: Correct handling of parameters passed to main. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« 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 /// 1 ///
2 /// Script to create boilerplate for a Polymer element. 2 /// Script to create boilerplate for a Polymer element.
3 /// Produces new .html entry point for a polymer app and updates the 3 /// Produces new .html entry point for a polymer app and updates the
4 /// pubspec.yaml to reflect it. 4 /// pubspec.yaml to reflect it.
5 /// 5 ///
6 /// Run this script with pub run: 6 /// Run this script with pub run:
7 /// 7 ///
8 /// pub run polymer:new_entry <html_file> 8 /// pub run polymer:new_entry <html_file>
9 /// 9 ///
10 import 'dart:io'; 10 import 'dart:io';
11 import 'package:args/args.dart'; 11 import 'package:args/args.dart';
12 import 'package:path/path.dart' as path; 12 import 'package:path/path.dart' as path;
13 import 'package:yaml/yaml.dart'; 13 import 'package:yaml/yaml.dart';
14 import 'package:source_span/source_span.dart'; 14 import 'package:source_span/source_span.dart';
15 15
16 void printUsage() { 16 void printUsage() {
17 print('pub run polymer:new_entry entry_point_file.html'); 17 print('pub run polymer:new_entry entry_point_file.html');
18 } 18 }
19 19
20 void main(List<String> args) { 20 void main(List<String> args) {
21 var parser = new ArgParser(allowTrailingOptions: true); 21 var parser = new ArgParser(allowTrailingOptions: true);
22 parser.addFlag('help', abbr: 'h'); 22 parser.addFlag('help', abbr: 'h');
23 var entryPoint; 23 var entryPoint;
24 24
25 try { 25 try {
26 var options = parser.parse(args); 26 var options = parser.parse(args);
27 if (options['help'] != null) { 27 if (options['help']) {
28 printUsage(); 28 printUsage();
29 return; 29 return;
30 } 30 }
31 entryPoint = options.rest[0]; 31 entryPoint = options.rest[0];
32 } catch(e) { 32 } catch(e) {
33 print('$e\n'); 33 print('$e\n');
34 printUsage(); 34 printUsage();
35 exitCode = 1; 35 exitCode = 1;
36 return; 36 return;
37 } 37 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 '${textToInsert}\n${pubspecText.substring(insertionPoint)}'; 179 '${textToInsert}\n${pubspecText.substring(insertionPoint)}';
180 } 180 }
181 181
182 _writePubspec(pubspecPath, pubspecText); 182 _writePubspec(pubspecPath, pubspecText);
183 return true; 183 return true;
184 } 184 }
185 185
186 _writePubspec(String pubspecPath, String text) { 186 _writePubspec(String pubspecPath, String text) {
187 new File(pubspecPath).writeAsStringSync(text); 187 new File(pubspecPath).writeAsStringSync(text);
188 } 188 }
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