File tree 2 files changed +17
-2
lines changed 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,7 @@ where
167
167
pub struct PathCompleter {
168
168
current_dir : Option < std:: path:: PathBuf > ,
169
169
filter : Option < Box < dyn Fn ( & std:: path:: Path ) -> bool + Send + Sync > > ,
170
+ stdio : bool ,
170
171
}
171
172
172
173
impl PathCompleter {
@@ -175,6 +176,7 @@ impl PathCompleter {
175
176
Self {
176
177
filter : None ,
177
178
current_dir : None ,
179
+ stdio : false ,
178
180
}
179
181
}
180
182
@@ -188,6 +190,12 @@ impl PathCompleter {
188
190
Self :: any ( ) . filter ( |p| p. is_dir ( ) )
189
191
}
190
192
193
+ /// Include stdio (`-`)
194
+ pub fn stdio ( mut self ) -> Self {
195
+ self . stdio = true ;
196
+ self
197
+ }
198
+
191
199
/// Select which paths should be completed
192
200
pub fn filter (
193
201
mut self ,
@@ -218,7 +226,11 @@ impl ValueCompleter for PathCompleter {
218
226
current_dir_actual = std:: env:: current_dir ( ) . ok ( ) ;
219
227
current_dir_actual. as_deref ( )
220
228
} ) ;
221
- complete_path ( current, current_dir, filter)
229
+ let mut candidates = complete_path ( current, current_dir, filter) ;
230
+ if self . stdio && current. is_empty ( ) {
231
+ candidates. push ( CompletionCandidate :: new ( "-" ) . help ( Some ( "stdio" . into ( ) ) ) ) ;
232
+ }
233
+ candidates
222
234
}
223
235
}
224
236
Original file line number Diff line number Diff line change @@ -592,7 +592,9 @@ fn suggest_value_path_file() {
592
592
. long ( "input" )
593
593
. short ( 'i' )
594
594
. add ( ArgValueCompleter :: new (
595
- PathCompleter :: file ( ) . current_dir ( testdir_path. to_owned ( ) ) ,
595
+ PathCompleter :: file ( )
596
+ . stdio ( )
597
+ . current_dir ( testdir_path. to_owned ( ) ) ,
596
598
) ) ,
597
599
)
598
600
. args_conflicts_with_subcommands ( true ) ;
@@ -604,6 +606,7 @@ a_file
604
606
b_file
605
607
c_dir/
606
608
d_dir/
609
+ - stdio
607
610
"# ] ] ,
608
611
) ;
609
612
You can’t perform that action at this time.
0 commit comments