OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 command_lish; | 5 library command_lish; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:json'; | 9 import 'dart:json'; |
10 import 'dart:uri'; | 10 import 'dart:uri'; |
(...skipping 14 matching lines...) Loading... | |
25 /// Handles the `lish` and `publish` pub commands. | 25 /// Handles the `lish` and `publish` pub commands. |
26 class LishCommand extends PubCommand { | 26 class LishCommand extends PubCommand { |
27 final description = "Publish the current package to pub.dartlang.org."; | 27 final description = "Publish the current package to pub.dartlang.org."; |
28 final usage = "pub publish [options]"; | 28 final usage = "pub publish [options]"; |
29 final aliases = const ["lish", "lush"]; | 29 final aliases = const ["lish", "lush"]; |
30 | 30 |
31 ArgParser get commandParser { | 31 ArgParser get commandParser { |
32 var parser = new ArgParser(); | 32 var parser = new ArgParser(); |
33 // TODO(nweiz): Use HostedSource.defaultUrl as the default value once we use | 33 // TODO(nweiz): Use HostedSource.defaultUrl as the default value once we use |
34 // dart:io for HTTPS requests. | 34 // dart:io for HTTPS requests. |
35 parser.addFlag('preview', abbr: 'p', negatable: false, | |
36 help: 'Preview publishing the package'); | |
nweiz
2013/02/09 00:20:50
Weren't we going to call this --dry-run?
keertip
2013/02/09 00:53:40
Not sure what we settled on in the end, but am OK
nweiz
2013/02/09 00:59:02
I'd prefer --dry-run, since that's consistent with
keertip
2013/02/09 04:05:47
Done.
| |
35 parser.addOption('server', defaultsTo: 'https://pub.dartlang.org', | 37 parser.addOption('server', defaultsTo: 'https://pub.dartlang.org', |
36 help: 'The package server to which to upload this package'); | 38 help: 'The package server to which to upload this package'); |
37 return parser; | 39 return parser; |
38 } | 40 } |
39 | 41 |
40 /// The URL of the server to which to upload the package. | 42 /// The URL of the server to which to upload the package. |
41 Uri get server => Uri.parse(commandOptions['server']); | 43 Uri get server => Uri.parse(commandOptions['server']); |
42 | 44 |
43 Future _publish(packageBytes) { | 45 Future _publish(packageBytes) { |
44 var cloudStorageUrl; | 46 var cloudStorageUrl; |
(...skipping 112 matching lines...) Loading... | |
157 "and can't be published yet.\nFor more information, see: " | 159 "and can't be published yet.\nFor more information, see: " |
158 "http://pub.dartlang.org/doc/pub-lish.html.\n"; | 160 "http://pub.dartlang.org/doc/pub-lish.html.\n"; |
159 } | 161 } |
160 | 162 |
161 var message = 'Looks great! Are you ready to upload your package'; | 163 var message = 'Looks great! Are you ready to upload your package'; |
162 | 164 |
163 if (!warnings.isEmpty) { | 165 if (!warnings.isEmpty) { |
164 var s = warnings.length == 1 ? '' : 's'; | 166 var s = warnings.length == 1 ? '' : 's'; |
165 message = "Package has ${warnings.length} warning$s. Upload anyway"; | 167 message = "Package has ${warnings.length} warning$s. Upload anyway"; |
166 } | 168 } |
169 | |
170 if (commandOptions['preview']){ | |
171 log.warning("Package has ${warnings.length} warnings."); | |
nweiz
2013/02/09 00:20:50
Nit: it would be nice to do the pluralization tric
keertip
2013/02/09 00:53:40
Done.
| |
172 exit(0); | |
173 } | |
nweiz
2013/02/09 00:20:50
Style nit: I'd move this block above the message a
keertip
2013/02/09 00:53:40
Done.
| |
167 | 174 |
168 return confirm(message).then((confirmed) { | 175 return confirm(message).then((confirmed) { |
169 if (!confirmed) throw "Package upload canceled."; | 176 if (!confirmed) throw "Package upload canceled."; |
170 }); | 177 }); |
171 }); | 178 }); |
172 } | 179 } |
173 } | 180 } |
OLD | NEW |