@@ -87,21 +87,18 @@ base mixin PubSupport on ToolsSupport, LoggingSupport, RootsTrackingSupport
8787 inputSchema: Schema .object (
8888 properties: {
8989 ParameterNames .command: Schema .string (
90- title: 'The pub command to run.' ,
91- description:
92- 'Currently only ${SupportedPubCommand .listAll } are supported.' ,
90+ title: 'The pub subcommand to run.' ,
91+ enumValues: SupportedPubCommand .values
92+ .map <String >((e) => e.name)
93+ .toList (),
94+ description: SupportedPubCommand .commandDescriptions,
9395 ),
9496 ParameterNames .packageNames: Schema .list (
9597 title: 'The package names to run the command for.' ,
9698 description:
9799 'This is required for the '
98100 '${SupportedPubCommand .listAllThatRequirePackageName } commands. ' ,
99- items: Schema .string (
100- title: 'A package to run the command for.' ,
101- description:
102- 'When used with "add", prefix with "dev:" to add the package '
103- 'as a dev dependency.' ,
104- ),
101+ items: Schema .string (title: 'A package to run the command for.' ),
105102 ),
106103 ParameterNames .roots: rootsSchema (),
107104 },
@@ -112,22 +109,49 @@ base mixin PubSupport on ToolsSupport, LoggingSupport, RootsTrackingSupport
112109
113110/// The set of supported `dart pub` subcommands.
114111enum SupportedPubCommand {
115- // This is supported in a simplified form: `dart pub add <package-name>`.
116- // TODO(https://github.com/dart-lang/ai/issues/77): add support for adding
117- // dev dependencies.
118- add (requiresPackageNames: true ),
119-
120- get ,
112+ add (
113+ requiresPackageNames: true ,
114+ description: '''Add package dependencies.
115+ - To add a package normally (typical): "pkg_name"
116+ - Git reference: "pkg_name:{git:{url: https://github.com/pkg_name/pkg_name.git, ref: branch, path: subdir}}"
117+ - ref and path are optional.
118+ - From local path: "pkg_name:{path: ../pkg_name}"
119+ - Dev Dependency: "dev:pkg_name"
120+ - Dependency override: "override:pkg_name:1.0.0"
121+ ''' ,
122+ ),
123+
124+ deps (description: 'Print the dependency tree of the current package.' ),
125+
126+ get (
127+ description: "Fetch the current package's dependencies and install them." ,
128+ ),
129+
130+ outdated (
131+ description: 'Analyze dependencies to find which ones can be upgraded.' ,
132+ ),
121133
122134 // This is supported in a simplified form: `dart pub remove <package-name>`.
123- remove (requiresPackageNames: true ),
135+ remove (
136+ requiresPackageNames: true ,
137+ description: 'Removes specified dependencies from `pubspec.yaml`.' ,
138+ ),
124139
125- upgrade;
140+ upgrade (
141+ description:
142+ "Upgrade the current package's dependencies to latest versions." ,
143+ );
126144
127- const SupportedPubCommand ({this .requiresPackageNames = false });
145+ const SupportedPubCommand ({
146+ this .requiresPackageNames = false ,
147+ required this .description,
148+ });
128149
129150 final bool requiresPackageNames;
130151
152+ /// The description to use in the subcommand help.
153+ final String description;
154+
131155 static SupportedPubCommand ? fromName (String name) {
132156 for (final command in SupportedPubCommand .values) {
133157 if (command.name == name) {
@@ -147,6 +171,22 @@ enum SupportedPubCommand {
147171 );
148172 }
149173
174+ static String get commandDescriptions {
175+ return 'Available subcommands:\n ${_getDescriptions (values )}' ;
176+ }
177+
178+ static String _getDescriptions (Iterable <SupportedPubCommand > commands) {
179+ final buffer = StringBuffer ();
180+ for (final command in commands) {
181+ final commandName = command.name;
182+ final description = command.description;
183+ if (description.isNotEmpty) {
184+ buffer.writeln ('- `$commandName `: $description ' );
185+ }
186+ }
187+ return buffer.toString ();
188+ }
189+
150190 static String _writeCommandsAsList (List <SupportedPubCommand > commands) {
151191 final buffer = StringBuffer ();
152192 for (var i = 0 ; i < commands.length; i++ ) {
0 commit comments