@@ -30,19 +30,25 @@ use anyhow::{bail, Context, Result};
3030/// `bin` should be either `kani` or `cargo-kani` 
3131pub  fn  proxy ( bin :  & str )  -> Result < ( ) >  { 
3232    // In an effort to keep our dependencies minimal, we do the bare minimum argument parsing 
33-     let  args:  Vec < _ >  = env:: args_os ( ) . collect ( ) ; 
34-     if  args. len ( )  >= 2  && args[ 1 ]  == "setup"  { 
35-         if  args. len ( )  >= 4  && args[ 2 ]  == "--use-local-bundle"  { 
33+     let  args:  Vec < OsString >  = env:: args_os ( ) . collect ( ) ; 
34+     // This makes it easy to do crude arg parsing with match 
35+     let  args_ez:  Vec < Option < & str > >  = args. iter ( ) . map ( |x| x. to_str ( ) ) . collect ( ) ; 
36+     // "cargo kani setup" comes in as "cargo-kani kani setup" 
37+     // "cargo-kani setup" comes in as "cargo-kani setup" 
38+     match  & args_ez[ ..]  { 
39+         & [ _,  Some ( "setup" ) ,  Some ( "--use-local-bundle" ) ,  _] 
40+         | & [ _,  Some ( "kani" ) ,  Some ( "setup" ) ,  Some ( "--use-local-bundle" ) ,  _]  => { 
41+             // Grab it from args, so it can be non-utf-8 
3642            setup:: setup ( Some ( args[ 3 ] . clone ( ) ) ) 
37-         }  else  { 
38-             setup:: setup ( None ) 
3943        } 
40-     }  else  { 
41-         fail_if_in_dev_environment ( ) ?; 
42-         if  !setup:: appears_setup ( )  { 
43-             setup:: setup ( None ) ?; 
44+         & [ _,  Some ( "setup" ) ]  | & [ _,  Some ( "kani" ) ,  Some ( "setup" ) ]  => setup:: setup ( None ) , 
45+         _ => { 
46+             fail_if_in_dev_environment ( ) ?; 
47+             if  !setup:: appears_setup ( )  { 
48+                 setup:: setup ( None ) ?; 
49+             } 
50+             exec ( bin) 
4451        } 
45-         exec ( bin) 
4652    } 
4753} 
4854
0 commit comments