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_uploader; | 5 library command_uploader; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:uri'; | 9 import 'dart:uri'; |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 // dart:io for HTTPS requests. | 31 // dart:io for HTTPS requests. |
32 parser.addOption('server', defaultsTo: 'https://pub.dartlang.org', | 32 parser.addOption('server', defaultsTo: 'https://pub.dartlang.org', |
33 help: 'The package server on which the package is hosted'); | 33 help: 'The package server on which the package is hosted'); |
34 parser.addOption('package', help: 'The package whose uploaders will be ' | 34 parser.addOption('package', help: 'The package whose uploaders will be ' |
35 'modified\n' | 35 'modified\n' |
36 '(defaults to the current package)'); | 36 '(defaults to the current package)'); |
37 return parser; | 37 return parser; |
38 } | 38 } |
39 | 39 |
40 /// The URL of the package hosting server. | 40 /// The URL of the package hosting server. |
41 Uri get server => new Uri.fromString(commandOptions['server']); | 41 Uri get server => Uri.parse(commandOptions['server']); |
42 | 42 |
43 Future onRun() { | 43 Future onRun() { |
44 if (commandOptions.rest.isEmpty) { | 44 if (commandOptions.rest.isEmpty) { |
45 log.error('No uploader command given.'); | 45 log.error('No uploader command given.'); |
46 this.printUsage(); | 46 this.printUsage(); |
47 exit(exit_codes.USAGE); | 47 exit(exit_codes.USAGE); |
48 } | 48 } |
49 | 49 |
50 var command = commandOptions.rest.removeAt(0); | 50 var command = commandOptions.rest.removeAt(0); |
51 if (!['add', 'remove'].contains(command)) { | 51 if (!['add', 'remove'].contains(command)) { |
(...skipping 23 matching lines...) Expand all Loading... |
75 "/uploaders/${encodeUriComponent(uploader)}.json"); | 75 "/uploaders/${encodeUriComponent(uploader)}.json"); |
76 return client.delete(url); | 76 return client.delete(url); |
77 } | 77 } |
78 }); | 78 }); |
79 }).then(handleJsonSuccess).catchError((asyncError) { | 79 }).then(handleJsonSuccess).catchError((asyncError) { |
80 if (asyncError.error is! PubHttpException) throw asyncError; | 80 if (asyncError.error is! PubHttpException) throw asyncError; |
81 handleJsonError(asyncError.error.response); | 81 handleJsonError(asyncError.error.response); |
82 }); | 82 }); |
83 } | 83 } |
84 } | 84 } |
OLD | NEW |