@@ -246,7 +246,11 @@ pub trait CommandExt: Sized {
246
246
"Space or comma separated list of features to activate" ,
247
247
)
248
248
. short ( 'F' )
249
- . help_heading ( heading:: FEATURE_SELECTION ) ,
249
+ . help_heading ( heading:: FEATURE_SELECTION )
250
+ . add ( clap_complete:: ArgValueCandidates :: new ( || {
251
+ let candidates = get_feature_candidates ( ) ;
252
+ candidates. unwrap_or_default ( )
253
+ } ) ) ,
250
254
)
251
255
. _arg (
252
256
flag ( "all-features" , "Activate all available features" )
@@ -1169,6 +1173,28 @@ fn default_profile_candidates() -> Vec<clap_complete::CompletionCandidate> {
1169
1173
]
1170
1174
}
1171
1175
1176
+ fn get_feature_candidates ( ) -> CargoResult < Vec < clap_complete:: CompletionCandidate > > {
1177
+ let gctx = new_gctx_for_completions ( ) ?;
1178
+ let manifest_path = find_root_manifest_for_wd ( gctx. cwd ( ) ) ?;
1179
+ let ws = Workspace :: new ( & manifest_path, & gctx) ?;
1180
+ let mut feature_candidates = Vec :: new ( ) ;
1181
+
1182
+ // Process all packages in the workspace
1183
+ for package in ws. members ( ) {
1184
+ let package_name = package. name ( ) ;
1185
+
1186
+ // Add direct features with package info
1187
+ for feature_name in package. summary ( ) . features ( ) . keys ( ) {
1188
+ feature_candidates. push (
1189
+ clap_complete:: CompletionCandidate :: new ( feature_name)
1190
+ . help ( Some ( format ! ( "(from {})" , package_name) . into ( ) ) ) ,
1191
+ ) ;
1192
+ }
1193
+ }
1194
+
1195
+ Ok ( feature_candidates)
1196
+ }
1197
+
1172
1198
fn get_example_candidates ( ) -> Vec < clap_complete:: CompletionCandidate > {
1173
1199
get_targets_from_metadata ( )
1174
1200
. unwrap_or_default ( )
0 commit comments