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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:path/path.dart' as path; | 7 import 'package:path/path.dart' as path; |
8 | 8 |
9 import '../command.dart'; | 9 import '../command.dart'; |
10 import '../entrypoint.dart'; | 10 import '../entrypoint.dart'; |
11 import '../exit_codes.dart' as exit_codes; | 11 import '../exit_codes.dart' as exit_codes; |
12 import '../http.dart'; | 12 import '../http.dart'; |
13 import '../io.dart'; | 13 import '../io.dart'; |
14 import '../log.dart' as log; | 14 import '../log.dart' as log; |
15 import '../oauth2.dart' as oauth2; | 15 import '../oauth2.dart' as oauth2; |
16 import '../source/hosted.dart'; | |
17 | 16 |
18 /// Handles the `uploader` pub command. | 17 /// Handles the `uploader` pub command. |
19 class UploaderCommand extends PubCommand { | 18 class UploaderCommand extends PubCommand { |
20 String get name => "uploader"; | 19 String get name => "uploader"; |
21 String get description => | 20 String get description => |
22 "Manage uploaders for a package on pub.dartlang.org."; | 21 "Manage uploaders for a package on pub.dartlang.org."; |
23 String get invocation => "pub uploader [options] {add/remove} <email>"; | 22 String get invocation => "pub uploader [options] {add/remove} <email>"; |
24 String get docUrl => "http://dartlang.org/tools/pub/cmd/pub-uploader.html"; | 23 String get docUrl => "http://dartlang.org/tools/pub/cmd/pub-uploader.html"; |
25 | 24 |
26 /// The URL of the package hosting server. | 25 /// The URL of the package hosting server. |
27 Uri get server => Uri.parse(argResults['server']); | 26 Uri get server => Uri.parse(argResults['server']); |
28 | 27 |
29 UploaderCommand() { | 28 UploaderCommand() { |
30 argParser.addOption('server', defaultsTo: HostedSource.defaultUrl, | 29 argParser.addOption('server', defaultsTo: cache.sources.hosted.defaultUrl, |
31 help: 'The package server on which the package is hosted.'); | 30 help: 'The package server on which the package is hosted.'); |
32 argParser.addOption('package', | 31 argParser.addOption('package', |
33 help: 'The package whose uploaders will be modified.\n' | 32 help: 'The package whose uploaders will be modified.\n' |
34 '(defaults to the current package)'); | 33 '(defaults to the current package)'); |
35 } | 34 } |
36 | 35 |
37 Future run() { | 36 Future run() { |
38 if (argResults.rest.isEmpty) { | 37 if (argResults.rest.isEmpty) { |
39 log.error('No uploader command given.'); | 38 log.error('No uploader command given.'); |
40 this.printUsage(); | 39 this.printUsage(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 "${Uri.encodeComponent(package)}/uploaders/" | 72 "${Uri.encodeComponent(package)}/uploaders/" |
74 "${Uri.encodeComponent(uploader)}"); | 73 "${Uri.encodeComponent(uploader)}"); |
75 return client.delete(url, headers: PUB_API_HEADERS); | 74 return client.delete(url, headers: PUB_API_HEADERS); |
76 } | 75 } |
77 }); | 76 }); |
78 }).then(handleJsonSuccess) | 77 }).then(handleJsonSuccess) |
79 .catchError((error) => handleJsonError(error.response), | 78 .catchError((error) => handleJsonError(error.response), |
80 test: (e) => e is PubHttpException); | 79 test: (e) => e is PubHttpException); |
81 } | 80 } |
82 } | 81 } |
OLD | NEW |