@@ -7,7 +7,7 @@ mod github;
77mod paths;
88mod tool_cache;
99
10- use std:: { env, error:: Error , io, path :: Path } ;
10+ use std:: { env, error:: Error , io} ;
1111
1212use structopt:: StructOpt ;
1313
@@ -20,19 +20,16 @@ struct ToolInvocation {
2020}
2121
2222impl ToolInvocation {
23- fn from_args ( ) -> Option < Self > {
24- let mut all_args = env:: args ( ) ;
25-
26- let app_path = all_args. next ( ) ?;
27- let as_path = Path :: new ( & app_path) ;
28- let name = as_path. file_stem ( ) ?. to_str ( ) ?. to_owned ( ) ;
23+ fn from_env ( ) -> Option < Self > {
24+ let app_path = env:: current_exe ( ) . unwrap ( ) ;
25+ let name = app_path. file_stem ( ) ?. to_str ( ) ?. to_owned ( ) ;
2926
3027 // That's us!
3128 if name == "foreman" {
3229 return None ;
3330 }
3431
35- let args = all_args . collect ( ) ;
32+ let args = env :: args ( ) . skip ( 1 ) . collect ( ) ;
3633
3734 Some ( Self { name, args } )
3835 }
@@ -48,7 +45,7 @@ fn main() -> Result<(), Box<dyn Error>> {
4845
4946 paths:: create ( ) ?;
5047
51- if let Some ( invocation) = ToolInvocation :: from_args ( ) {
48+ if let Some ( invocation) = ToolInvocation :: from_env ( ) {
5249 let config = ConfigFile :: aggregate ( ) ?;
5350
5451 if let Some ( tool_spec) = config. tools . get ( & invocation. name ) {
0 commit comments