OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import 'dart:io'; | 6 import 'dart:io'; |
7 | 7 |
8 import 'package:args/args.dart'; | 8 import 'package:args/args.dart'; |
9 import 'package:http/http.dart' as http; | 9 import 'package:http/http.dart' as http; |
10 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; |
11 import 'package:stack_trace/stack_trace.dart'; | 11 import 'package:stack_trace/stack_trace.dart'; |
12 | 12 |
13 import '../lib/src/command.dart'; | 13 import '../lib/src/command.dart'; |
14 import '../lib/src/exceptions.dart'; | 14 import '../lib/src/exceptions.dart'; |
15 import '../lib/src/exit_codes.dart' as exit_codes; | 15 import '../lib/src/exit_codes.dart' as exit_codes; |
16 import '../lib/src/http.dart'; | 16 import '../lib/src/http.dart'; |
17 import '../lib/src/io.dart'; | 17 import '../lib/src/io.dart'; |
18 import '../lib/src/log.dart' as log; | 18 import '../lib/src/log.dart' as log; |
19 import '../lib/src/sdk.dart' as sdk; | 19 import '../lib/src/sdk.dart' as sdk; |
| 20 import '../lib/src/solver/version_solver.dart'; |
20 import '../lib/src/utils.dart'; | 21 import '../lib/src/utils.dart'; |
21 | 22 |
22 void main(List<String> arguments) { | 23 void main(List<String> arguments) { |
23 ArgResults options; | 24 ArgResults options; |
24 | 25 |
25 try { | 26 try { |
26 options = PubCommand.pubArgParser.parse(arguments); | 27 options = PubCommand.pubArgParser.parse(arguments); |
27 } on FormatException catch (e) { | 28 } on FormatException catch (e) { |
28 log.error(e.message); | 29 log.error(e.message); |
29 log.error('Run "pub help" to see available options.'); | 30 log.error('Run "pub help" to see available options.'); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 return flushThenExit(exit_codes.SUCCESS); | 109 return flushThenExit(exit_codes.SUCCESS); |
109 }); | 110 }); |
110 } | 111 } |
111 | 112 |
112 /// Returns the appropriate exit code for [exception], falling back on 1 if no | 113 /// Returns the appropriate exit code for [exception], falling back on 1 if no |
113 /// appropriate exit code could be found. | 114 /// appropriate exit code could be found. |
114 int chooseExitCode(exception) { | 115 int chooseExitCode(exception) { |
115 while (exception is WrappedException) exception = exception.innerError; | 116 while (exception is WrappedException) exception = exception.innerError; |
116 | 117 |
117 if (exception is HttpException || exception is http.ClientException || | 118 if (exception is HttpException || exception is http.ClientException || |
118 exception is SocketException || exception is PubHttpException) { | 119 exception is SocketException || exception is PubHttpException || |
| 120 exception is DependencyNotFoundException) { |
119 return exit_codes.UNAVAILABLE; | 121 return exit_codes.UNAVAILABLE; |
120 } else if (exception is FormatException || exception is DataException) { | 122 } else if (exception is FormatException || exception is DataException) { |
121 return exit_codes.DATA; | 123 return exit_codes.DATA; |
122 } else if (exception is UsageException) { | 124 } else if (exception is UsageException) { |
123 return exit_codes.USAGE; | 125 return exit_codes.USAGE; |
124 } else { | 126 } else { |
125 return 1; | 127 return 1; |
126 } | 128 } |
127 } | 129 } |
128 | 130 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 if (Platform.operatingSystem != 'windows') return null; | 190 if (Platform.operatingSystem != 'windows') return null; |
189 | 191 |
190 return runProcess('ver', []).then((result) { | 192 return runProcess('ver', []).then((result) { |
191 if (result.stdout.join('\n').contains('XP')) { | 193 if (result.stdout.join('\n').contains('XP')) { |
192 log.error('Sorry, but pub is not supported on Windows XP.'); | 194 log.error('Sorry, but pub is not supported on Windows XP.'); |
193 return flushThenExit(exit_codes.USAGE); | 195 return flushThenExit(exit_codes.USAGE); |
194 } | 196 } |
195 }); | 197 }); |
196 }); | 198 }); |
197 } | 199 } |
OLD | NEW |