Use 'pkg' and 'packages' to trigger suggestions for the pub command (#3731)
diff --git a/lib/src/pub_embeddable_command.dart b/lib/src/pub_embeddable_command.dart index a12efe4..29ac73f 100644 --- a/lib/src/pub_embeddable_command.dart +++ b/lib/src/pub_embeddable_command.dart
@@ -47,6 +47,10 @@ class PubEmbeddableCommand extends PubCommand implements PubTopLevel { @override String get name => 'pub'; + + @override + get suggestionAliases => const ['packages', 'pkg']; + @override String get description => 'Work with packages.'; @override
diff --git a/pubspec.yaml b/pubspec.yaml index d34a3f5..447ee06 100644 --- a/pubspec.yaml +++ b/pubspec.yaml
@@ -7,7 +7,7 @@ # Note: Pub's test infrastructure assumes that any dependencies used in tests # will be hosted dependencies. analyzer: ^5.1.0 - args: ^2.1.0 + args: ^2.4.0 async: ^2.6.1 cli_util: ^0.3.5 collection: ^1.15.0
diff --git a/test/embedding/embedding_test.dart b/test/embedding/embedding_test.dart index a234ec2..8a7d59b 100644 --- a/test/embedding/embedding_test.dart +++ b/test/embedding/embedding_test.dart
@@ -7,6 +7,7 @@ import 'package:path/path.dart' as path; import 'package:path/path.dart' as p; +import 'package:pub/src/exit_codes.dart'; import 'package:pub/src/io.dart' show EnvironmentKeys; import 'package:test/test.dart'; import 'package:test_process/test_process.dart'; @@ -392,6 +393,27 @@ ), ); }); + + test('"pkg" and "packages" will trigger a suggestion of "pub"', () async { + await servePackages(); + await d.appDir().create(); + for (final command in ['pkg', 'packages']) { + final buffer = StringBuffer(); + await runEmbeddingToBuffer( + [command, 'get'], + buffer, + workingDirectory: d.path(appPath), + exitCode: USAGE, + ); + expect( + buffer.toString(), + allOf( + contains('Did you mean one of these?'), + contains(' pub'), + ), + ); + } + }); } String _filter(String input) {