| 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 'package:args/args.dart'; | 5 import 'package:args/args.dart'; |
| 6 import 'package:args/command_runner.dart'; | 6 import 'package:args/command_runner.dart'; |
| 7 | 7 |
| 8 import 'entrypoint.dart'; | 8 import 'entrypoint.dart'; |
| 9 import 'log.dart' as log; | 9 import 'log.dart' as log; |
| 10 import 'global_packages.dart'; | 10 import 'global_packages.dart'; |
| 11 import 'system_cache.dart'; | 11 import 'system_cache.dart'; |
| 12 | 12 |
| 13 /// The base class for commands for the pub executable. | 13 /// The base class for commands for the pub executable. |
| 14 /// | 14 /// |
| 15 /// A command may either be a "leaf" command or it may be a parent for a set | 15 /// A command may either be a "leaf" command or it may be a parent for a set |
| 16 /// of subcommands. Only leaf commands are ever actually invoked. If a command | 16 /// of subcommands. Only leaf commands are ever actually invoked. If a command |
| 17 /// has subcommands, then one of those must always be chosen. | 17 /// has subcommands, then one of those must always be chosen. |
| 18 abstract class PubCommand extends Command { | 18 abstract class PubCommand extends Command { |
| 19 SystemCache get cache { | 19 SystemCache get cache { |
| 20 if (_cache == null) { | 20 if (_cache == null) _cache = new SystemCache(isOffline: isOffline); |
| 21 _cache = new SystemCache.withSources(isOffline: isOffline); | |
| 22 } | |
| 23 return _cache; | 21 return _cache; |
| 24 } | 22 } |
| 25 SystemCache _cache; | 23 SystemCache _cache; |
| 26 | 24 |
| 27 GlobalPackages get globals { | 25 GlobalPackages get globals { |
| 28 if (_globals == null) { | 26 if (_globals == null) { |
| 29 _globals = new GlobalPackages(cache); | 27 _globals = new GlobalPackages(cache); |
| 30 } | 28 } |
| 31 return _globals; | 29 return _globals; |
| 32 } | 30 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 /// | 80 /// |
| 83 /// If the parsing fails, prints a usage message and exits. | 81 /// If the parsing fails, prints a usage message and exits. |
| 84 int parseInt(String intString, String name) { | 82 int parseInt(String intString, String name) { |
| 85 try { | 83 try { |
| 86 return int.parse(intString); | 84 return int.parse(intString); |
| 87 } on FormatException catch (_) { | 85 } on FormatException catch (_) { |
| 88 usageException('Could not parse $name "$intString".'); | 86 usageException('Could not parse $name "$intString".'); |
| 89 } | 87 } |
| 90 } | 88 } |
| 91 } | 89 } |
| OLD | NEW |