@@ -182,33 +182,7 @@ fn aliased_command(gctx: &GlobalContext, command: &str) -> CargoResult<Option<Ve
182
182
183
183
/// List all runnable commands
184
184
fn list_commands ( gctx : & GlobalContext ) -> BTreeMap < String , CommandInfo > {
185
- let prefix = "cargo-" ;
186
- let suffix = env:: consts:: EXE_SUFFIX ;
187
- let mut commands = BTreeMap :: new ( ) ;
188
- for dir in search_directories ( gctx) {
189
- let entries = match fs:: read_dir ( dir) {
190
- Ok ( entries) => entries,
191
- _ => continue ,
192
- } ;
193
- for entry in entries. filter_map ( |e| e. ok ( ) ) {
194
- let path = entry. path ( ) ;
195
- let Some ( filename) = path. file_name ( ) . and_then ( |s| s. to_str ( ) ) else {
196
- continue ;
197
- } ;
198
- let Some ( name) = filename
199
- . strip_prefix ( prefix)
200
- . and_then ( |s| s. strip_suffix ( suffix) )
201
- else {
202
- continue ;
203
- } ;
204
- if is_executable ( entry. path ( ) ) {
205
- commands. insert (
206
- name. to_string ( ) ,
207
- CommandInfo :: External { path : path. clone ( ) } ,
208
- ) ;
209
- }
210
- }
211
- }
185
+ let mut commands = third_party_subcommands ( gctx) ;
212
186
213
187
for cmd in commands:: builtin ( ) {
214
188
commands. insert (
@@ -253,6 +227,37 @@ fn list_commands(gctx: &GlobalContext) -> BTreeMap<String, CommandInfo> {
253
227
commands
254
228
}
255
229
230
+ fn third_party_subcommands ( gctx : & GlobalContext ) -> BTreeMap < String , CommandInfo > {
231
+ let prefix = "cargo-" ;
232
+ let suffix = env:: consts:: EXE_SUFFIX ;
233
+ let mut commands = BTreeMap :: new ( ) ;
234
+ for dir in search_directories ( gctx) {
235
+ let entries = match fs:: read_dir ( dir) {
236
+ Ok ( entries) => entries,
237
+ _ => continue ,
238
+ } ;
239
+ for entry in entries. filter_map ( |e| e. ok ( ) ) {
240
+ let path = entry. path ( ) ;
241
+ let Some ( filename) = path. file_name ( ) . and_then ( |s| s. to_str ( ) ) else {
242
+ continue ;
243
+ } ;
244
+ let Some ( name) = filename
245
+ . strip_prefix ( prefix)
246
+ . and_then ( |s| s. strip_suffix ( suffix) )
247
+ else {
248
+ continue ;
249
+ } ;
250
+ if is_executable ( entry. path ( ) ) {
251
+ commands. insert (
252
+ name. to_string ( ) ,
253
+ CommandInfo :: External { path : path. clone ( ) } ,
254
+ ) ;
255
+ }
256
+ }
257
+ }
258
+ commands
259
+ }
260
+
256
261
fn find_external_subcommand ( gctx : & GlobalContext , cmd : & str ) -> Option < PathBuf > {
257
262
let command_exe = format ! ( "cargo-{}{}" , cmd, env:: consts:: EXE_SUFFIX ) ;
258
263
search_directories ( gctx)
0 commit comments