File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -9,11 +9,21 @@ fn main() {
9
9
}
10
10
} ;
11
11
12
+ #[ cfg( not( windows) ) ]
12
13
let result = match std:: env:: var ( "OPEN_WITH" ) . ok ( ) {
13
14
Some ( program) => open:: with ( & path_or_url, program) ,
14
15
None => open:: that ( & path_or_url) ,
15
16
} ;
16
17
18
+ #[ cfg( windows) ]
19
+ let result = match env:: args ( ) . nth ( 2 ) {
20
+ Some ( arg) if arg == "--with" || arg == "-w" => match env:: args ( ) . nth ( 3 ) {
21
+ Some ( program) => open:: with ( & path_or_url, program) ,
22
+ None => open:: that ( & path_or_url) ,
23
+ } ,
24
+ _ => open:: that ( & path_or_url) ,
25
+ } ;
26
+
17
27
match result {
18
28
Ok ( ( ) ) => println ! ( "Opened '{}' successfully." , path_or_url) ,
19
29
Err ( err) => {
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ pub fn commands<T: AsRef<OsStr>>(path: T) -> Vec<Command> {
20
20
pub fn with_command < T : AsRef < OsStr > > ( path : T , app : impl Into < String > ) -> Command {
21
21
let mut cmd = Command :: new ( "cmd" ) ;
22
22
cmd. arg ( "/c" )
23
+ . arg ( "start" )
24
+ . raw_arg ( "\" \" " )
23
25
. raw_arg ( app. into ( ) )
24
26
. raw_arg ( wrap_in_quotes ( path) )
25
27
. creation_flags ( CREATE_NO_WINDOW ) ;
You can’t perform that action at this time.
0 commit comments