Chromium Code Reviews

Side by Side Diff: sdk/lib/_internal/pub/lib/src/command/lish.dart

Issue 138723005: Support subcommands in pub and pub help. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
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 pub.command.lish; 5 library pub.command.lish;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:http/http.dart' as http; 9 import 'package:http/http.dart' as http;
10 10
11 import '../command.dart'; 11 import '../command.dart';
12 import '../directory_tree.dart'; 12 import '../directory_tree.dart';
13 import '../exit_codes.dart' as exit_codes;
14 import '../http.dart'; 13 import '../http.dart';
15 import '../io.dart'; 14 import '../io.dart';
16 import '../log.dart' as log; 15 import '../log.dart' as log;
17 import '../oauth2.dart' as oauth2; 16 import '../oauth2.dart' as oauth2;
18 import '../source/hosted.dart'; 17 import '../source/hosted.dart';
19 import '../utils.dart'; 18 import '../utils.dart';
20 import '../validator.dart'; 19 import '../validator.dart';
21 20
22 /// Handles the `lish` and `publish` pub commands. 21 /// Handles the `lish` and `publish` pub commands.
23 class LishCommand extends PubCommand { 22 class LishCommand extends PubCommand {
(...skipping 63 matching lines...)
87 } else if (urisEqual(Uri.parse(url.origin), Uri.parse(server.origin))) { 86 } else if (urisEqual(Uri.parse(url.origin), Uri.parse(server.origin))) {
88 handleJsonError(error.response); 87 handleJsonError(error.response);
89 } else { 88 } else {
90 throw error; 89 throw error;
91 } 90 }
92 }); 91 });
93 } 92 }
94 93
95 Future onRun() { 94 Future onRun() {
96 if (force && dryRun) { 95 if (force && dryRun) {
97 log.error('Cannot use both --force and --dry-run.'); 96 usageError('Cannot use both --force and --dry-run.');
98 this.printUsage();
99 return flushThenExit(exit_codes.USAGE);
100 } 97 }
101 98
102 var packageBytesFuture = entrypoint.packageFiles().then((files) { 99 var packageBytesFuture = entrypoint.packageFiles().then((files) {
103 log.fine('Archiving and publishing ${entrypoint.root}.'); 100 log.fine('Archiving and publishing ${entrypoint.root}.');
104 101
105 // Show the package contents so the user can verify they look OK. 102 // Show the package contents so the user can verify they look OK.
106 var package = entrypoint.root; 103 var package = entrypoint.root;
107 log.message( 104 log.message(
108 'Publishing ${package.name} ${package.version} to $server:\n' 105 'Publishing ${package.name} ${package.version} to $server:\n'
109 '${generateTree(files, baseDir: entrypoint.root.dir)}'); 106 '${generateTree(files, baseDir: entrypoint.root.dir)}');
(...skipping 27 matching lines...)
137 "${(errors.length > 1) ? 'some requirements' : 'a requirement'} " 134 "${(errors.length > 1) ? 'some requirements' : 'a requirement'} "
138 "and can't be published yet.\nFor more information, see: " 135 "and can't be published yet.\nFor more information, see: "
139 "http://pub.dartlang.org/doc/pub-lish.html.\n"); 136 "http://pub.dartlang.org/doc/pub-lish.html.\n");
140 return false; 137 return false;
141 } 138 }
142 139
143 if (force) return true; 140 if (force) return true;
144 141
145 if (dryRun) { 142 if (dryRun) {
146 var s = warnings.length == 1 ? '' : 's'; 143 var s = warnings.length == 1 ? '' : 's';
147 log.warning("Package has ${warnings.length} warning$s."); 144 log.warning("\nPackage has ${warnings.length} warning$s.");
148 return false; 145 return false;
149 } 146 }
150 147
151 var message = 'Looks great! Are you ready to upload your package'; 148 var message = '\nLooks great! Are you ready to upload your package';
152 149
153 if (!warnings.isEmpty) { 150 if (!warnings.isEmpty) {
154 var s = warnings.length == 1 ? '' : 's'; 151 var s = warnings.length == 1 ? '' : 's';
155 message = "Package has ${warnings.length} warning$s. Upload anyway"; 152 message = "\nPackage has ${warnings.length} warning$s. Upload anyway";
156 } 153 }
157 154
158 return confirm(message).then((confirmed) { 155 return confirm(message).then((confirmed) {
159 if (!confirmed) { 156 if (!confirmed) {
160 log.error("Package upload canceled."); 157 log.error("Package upload canceled.");
161 return false; 158 return false;
162 } 159 }
163 return true; 160 return true;
164 }); 161 });
165 }); 162 });
166 } 163 }
167 } 164 }
OLDNEW

Powered by Google App Engine