@@ -30,19 +30,25 @@ use anyhow::{bail, Context, Result};
30
30
/// `bin` should be either `kani` or `cargo-kani`
31
31
pub fn proxy ( bin : & str ) -> Result < ( ) > {
32
32
// 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
36
42
setup:: setup ( Some ( args[ 3 ] . clone ( ) ) )
37
- } else {
38
- setup:: setup ( None )
39
43
}
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)
44
51
}
45
- exec ( bin)
46
52
}
47
53
}
48
54
0 commit comments