|
| 1 | +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 | + |
| 5 | +import 'dart:async'; |
| 6 | + |
| 7 | +import 'package:pub/src/command/cache.dart'; |
| 8 | +import 'package:pub/src/command/deps.dart'; |
| 9 | +import 'package:pub/src/command/downgrade.dart'; |
| 10 | +import 'package:pub/src/command/get.dart'; |
| 11 | +import 'package:pub/src/command/global.dart'; |
| 12 | +import 'package:pub/src/command/lish.dart'; |
| 13 | +import 'package:pub/src/command/list_package_dirs.dart'; |
| 14 | +import 'package:pub/src/command/logout.dart'; |
| 15 | +import 'package:pub/src/command/run.dart'; |
| 16 | +import 'package:pub/src/command/serve.dart'; |
| 17 | +import 'package:pub/src/command/upgrade.dart'; |
| 18 | +import 'package:pub/src/command/uploader.dart'; |
| 19 | +import 'package:pub/src/command_runner.dart'; |
| 20 | + |
| 21 | +import '../core.dart'; |
| 22 | +import '../utils.dart'; |
| 23 | + |
| 24 | +class PubCommand extends DartdevCommand<int> { |
| 25 | + var pubCommandRunner = PubCommandRunner(); |
| 26 | + |
| 27 | + PubCommand({bool verbose = false}) |
| 28 | + : super('pub', 'Pub is a package manager for Dart.') { |
| 29 | + argParser.addFlag('version', negatable: false, help: 'Print pub version.'); |
| 30 | + argParser.addFlag('trace', |
| 31 | + help: 'Print debugging information when an error occurs.'); |
| 32 | + argParser |
| 33 | + .addOption('verbosity', help: 'Control output verbosity.', allowed: [ |
| 34 | + 'error', |
| 35 | + 'warning', |
| 36 | + 'normal', |
| 37 | + 'io', |
| 38 | + 'solver', |
| 39 | + 'all' |
| 40 | + ], allowedHelp: { |
| 41 | + 'error': 'Show only errors.', |
| 42 | + 'warning': 'Show only errors and warnings.', |
| 43 | + 'normal': 'Show errors, warnings, and user messages.', |
| 44 | + 'io': 'Also show IO operations.', |
| 45 | + 'solver': 'Show steps during version resolution.', |
| 46 | + 'all': 'Show all output including internal tracing messages.' |
| 47 | + }); |
| 48 | + argParser.addFlag('verbose', |
| 49 | + abbr: 'v', negatable: false, help: 'Shortcut for "--verbosity=all".'); |
| 50 | + argParser.addFlag('with-prejudice', |
| 51 | + hide: !isAprilFools, |
| 52 | + negatable: false, |
| 53 | + help: 'Execute commands with prejudice.'); |
| 54 | + argParser.addFlag('sparkle', |
| 55 | + hide: !isAprilFools, |
| 56 | + negatable: false, |
| 57 | + help: 'A more sparkly experience.'); |
| 58 | + |
| 59 | + addSubcommand(CacheCommand()); |
| 60 | + addSubcommand(DepsCommand()); |
| 61 | + addSubcommand(DowngradeCommand()); |
| 62 | + addSubcommand(GlobalCommand()); |
| 63 | + addSubcommand(GetCommand()); |
| 64 | + addSubcommand(ListPackageDirsCommand()); |
| 65 | + addSubcommand(LishCommand()); |
| 66 | + addSubcommand(RunCommand()); |
| 67 | + addSubcommand(ServeCommand()); |
| 68 | + addSubcommand(UpgradeCommand()); |
| 69 | + addSubcommand(UploaderCommand()); |
| 70 | + addSubcommand(LogoutCommand()); |
| 71 | + } |
| 72 | + |
| 73 | + @override |
| 74 | + FutureOr<int> run() async { |
| 75 | + await pubCommandRunner.run(argResults.arguments); |
| 76 | + return 0; |
| 77 | + } |
| 78 | +} |
0 commit comments