File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 1
1
use crate :: command_prelude:: * ;
2
+ use crate :: util:: toml:: is_embedded;
2
3
3
4
use anyhow:: anyhow;
4
5
use anyhow:: bail;
@@ -12,6 +13,8 @@ use itertools::Itertools;
12
13
use semver:: VersionReq ;
13
14
14
15
use cargo_util:: paths;
16
+ use std:: ffi:: OsStr ;
17
+ use std:: path:: Path ;
15
18
16
19
pub fn cli ( ) -> Command {
17
20
subcommand ( "install" )
@@ -65,7 +68,21 @@ pub fn cli() -> Command {
65
68
. arg (
66
69
opt ( "path" , "Filesystem path to local crate to install from" )
67
70
. value_name ( "PATH" )
68
- . conflicts_with_all ( & [ "git" , "index" , "registry" ] ) ,
71
+ . conflicts_with_all ( & [ "git" , "index" , "registry" ] )
72
+ . add ( clap_complete:: engine:: ArgValueCompleter :: new (
73
+ clap_complete:: engine:: PathCompleter :: any ( ) . filter ( |path : & Path | {
74
+ if path. is_dir ( ) {
75
+ return path. join ( "Cargo.toml" ) . exists ( ) ;
76
+ }
77
+ if path. file_name ( ) == Some ( OsStr :: new ( "Cargo.toml" ) ) {
78
+ return true ;
79
+ }
80
+ if is_embedded ( path) {
81
+ return true ;
82
+ }
83
+ false
84
+ } ) ,
85
+ ) ) ,
69
86
)
70
87
. arg ( opt ( "root" , "Directory to install packages into" ) . value_name ( "DIR" ) )
71
88
. arg ( flag ( "force" , "Force overwriting existing crates or binaries" ) . short ( 'f' ) )
You can’t perform that action at this time.
0 commit comments