fn process_command_line() -> CVResult<Opt> {
    // cargo-verify can be called directly, or by placing it on the `PATH` and
    // calling it through `cargo` (i.e. `cargo verify ...`.
    let mut args: Vec<_> = std::env::args().collect();
    if args.get(1).map(AsRef::as_ref) == Some("verify") {
        // Looks like the script was invoked by `cargo verify` - we have to
        // remove the second argument.
        args.remove(1);
    }
    let mut opt = Opt::from_iter(args.into_iter());
    // let mut opt = Opt::from_args();

    // Set verbosity early so that info_at! can be used
    opt.verbosity = if opt.quiet {
        Verbosity::Quiet
    } else {
        match opt.verbose {
            0 => Verbosity::Normal,
            1 => Verbosity::Informative,
            2 => Verbosity::Major,
            3 => Verbosity::Minor,
            _ => Verbosity::Trivial,
        }
    };

    if let Some(script) = &opt.script_arg {
        fs::remove_file(script).unwrap_or(());
        opt.script = Some(Mutex::new(
            OpenOptions::new().create(true).append(true).open(script)?,
        ));
    }

    opt.backend = match opt.backend_arg {
        // Check if the backend that was specified on the CL is installed.
        Some(Backend::Proptest) => {
            if opt.output.is_some() {
                Err("backend proptest does not support --output")?;
            }
            assert!(proptest::check_install());
            Backend::Proptest
        }
        Some(Backend::Klee) => {
            if !klee::check_install() {
                Err("Klee is not installed")?;
            }
            Backend::Klee
        }
        Some(Backend::Seahorn) => {
            if !seahorn::check_install() {
                Err("Seahorn is not installed")?;
            }
            Backend::Seahorn
        }
        Some(Backend::Smack) => {
            if !smack::check_install() {
                Err("SMACK is not installed")?;
            }
            Backend::Smack
        }
        None => {
            // If the user did not specify a backend, use the first one that we find.
            let backend = if klee::check_install() {
                Backend::Klee
            } else if seahorn::check_install() {
                Backend::Seahorn
            } else {
                assert!(proptest::check_install());
                Backend::Proptest
            };
            info_at!(&opt, Verbosity::Normal, "Using {} as backend", backend);
            backend
        }
    };

    // To be compatible with `cargo test`, features might be space separated.
    opt.features = opt
        .features
        .iter()
        .flat_map(|s| s.split(' '))
        .map(String::from)
        .collect::<Vec<_>>();

    // Backend specific options.
    match opt.backend {
        Backend::Proptest => {
            if opt.replay > 0 && !opt.args.is_empty() {
                Err("The Proptest backend does not support '--replay' and passing arguments together.")?;
            }
        }
        Backend::Seahorn => {
            if !opt.args.is_empty() {
                Err("The Seahorn backend does not support passing arguments yet.")?;
            }
            if opt.replay != 0 {
                Err("The Seahorn backend does not support '--replay' yet.")?;
            }

            opt.features.push(String::from("verifier-seahorn"));
        }
        Backend::Smack => {
            if !opt.args.is_empty() {
                Err("The SMACK backend does not support passing arguments yet.")?;
            }
            if opt.replay != 0 {
                Err("The SMACK backend does not support '--replay' yet.")?;
            }

            opt.features.push(String::from("verifier-smack"));
        }
        Backend::Klee => {
            opt.features.push(String::from("verifier-klee"));
        }
    }

    // Use the user specified number of jobs, or the number of CPUs.
    opt.jobs = opt.jobs_arg.unwrap_or(num_cpus::get());

    Ok(opt)
}
/// Parse the command line and make sure it makes sense.
Parse the command line and make sure it makes sense.
Parse the command line and make sure it makes sense .
fn process_command_line() -> CVResult<Opt> {
    // cargo-verify can be called directly, or by placing it on the `PATH` and
    // calling it through `cargo` (i.e. `cargo verify ...`.
    let mut args: Vec<_> = std::env::args().collect();
    if args.get(1).map(AsRef::as_ref) == Some("verify") {
        // Looks like the script was invoked by `cargo verify` - we have to
        // remove the second argument.
        args.remove(1);
    }
    let mut opt = Opt::from_iter(args.into_iter());
    // let mut opt = Opt::from_args();
    // Set verbosity early so that info_at! can be used
    opt.verbosity = if opt.quiet {
        Verbosity::Quiet
    } else {
        match opt.verbose {
            0 => Verbosity::Normal,
            1 => Verbosity::Informative,
            2 => Verbosity::Major,
            3 => Verbosity::Minor,
            _ => Verbosity::Trivial,
        }
    };
    if let Some(script) = &opt.script_arg {
        fs::remove_file(script).unwrap_or(());
        opt.script = Some(Mutex::new(
            OpenOptions::new().create(true).append(true).open(script)?,
        ));
    }
    opt.backend = match opt.backend_arg {
        // Check if the backend that was specified on the CL is installed.
        Some(Backend::Proptest) => {
            if opt.output.is_some() {
                Err("backend proptest does not support --output")?;
            }
            assert!(proptest::check_install());
            Backend::Proptest
        }
        Some(Backend::Klee) => {
            if !klee::check_install() {
                Err("Klee is not installed")?;
            }
            Backend::Klee
        }
        Some(Backend::Seahorn) => {
            if !seahorn::check_install() {
                Err("Seahorn is not installed")?;
            }
            Backend::Seahorn
        }
        Some(Backend::Smack) => {
            if !smack::check_install() {
                Err("SMACK is not installed")?;
            }
            Backend::Smack
        }
        None => {
            // If the user did not specify a backend, use the first one that we find.
            let backend = if klee::check_install() {
                Backend::Klee
            } else if seahorn::check_install() {
                Backend::Seahorn
            } else {
                assert!(proptest::check_install());
                Backend::Proptest
            };
            info_at!(&opt, Verbosity::Normal, "Using {} as backend", backend);
            backend
        }
    };
    // To be compatible with `cargo test`, features might be space separated.
    opt.features = opt
        .features
        .iter()
        .flat_map(|s| s.split(' '))
        .map(String::from)
        .collect::<Vec<_>>();
    // Backend specific options.
    match opt.backend {
        Backend::Proptest => {
            if opt.replay > 0 && !opt.args.is_empty() {
                Err("The Proptest backend does not support '--replay' and passing arguments together.")?;
            }
        }
        Backend::Seahorn => {
            if !opt.args.is_empty() {
                Err("The Seahorn backend does not support passing arguments yet.")?;
            }
            if opt.replay != 0 {
                Err("The Seahorn backend does not support '--replay' yet.")?;
            }
            opt.features.push(String::from("verifier-seahorn"));
        }
        Backend::Smack => {
            if !opt.args.is_empty() {
                Err("The SMACK backend does not support passing arguments yet.")?;
            }
            if opt.replay != 0 {
                Err("The SMACK backend does not support '--replay' yet.")?;
            }
            opt.features.push(String::from("verifier-smack"));
        }
        Backend::Klee => {
            opt.features.push(String::from("verifier-klee"));
        }
    }
    // Use the user specified number of jobs, or the number of CPUs.
    opt.jobs = opt.jobs_arg.unwrap_or(num_cpus::get());
    Ok(opt)
}
fn process_command_line ( ) -> CVResult < Opt > { // cargo-verify can be called directly, or by placing it on the `PATH` and // calling it through `cargo` (i.e. `cargo verify ...`. let mut args : Vec < _ > = std :: env :: args ( ) . collect ( ) ; if args . get ( 1 ) . map ( AsRef :: as_ref ) == Some ( " " ) { // Looks like the script was invoked by `cargo verify` - we have to // remove the second argument. args . remove ( 1 ) ; } let mut opt = Opt :: from_iter ( args . into_iter ( ) ) ; // let mut opt = Opt::from_args(); // Set verbosity early so that info_at! can be used opt . verbosity = if opt . quiet { Verbosity :: Quiet } else { match opt . verbose { 0 => Verbosity :: Normal , 1 => Verbosity :: Informative , 2 => Verbosity :: Major , 3 => Verbosity :: Minor , _ => Verbosity :: Trivial , } } ; if let Some ( script ) = & opt . script_arg { fs :: remove_file ( script ) . unwrap_or ( ( ) ) ; opt . script = Some ( Mutex :: new ( OpenOptions :: new ( ) . create ( true ) . append ( true ) . open ( script ) ? , ) ) ; } opt . backend = match opt . backend_arg { // Check if the backend that was specified on the CL is installed. Some ( Backend :: Proptest ) => { if opt . output . is_some ( ) { Err ( " " ) ? ; } assert ! ( proptest check_install ( ) ) ; Backend :: Proptest } Some ( Backend :: Klee ) => { if ! klee :: check_install ( ) { Err ( " " ) ? ; } Backend :: Klee } Some ( Backend :: Seahorn ) => { if ! seahorn :: check_install ( ) { Err ( " " ) ? ; } Backend :: Seahorn } Some ( Backend :: Smack ) => { if ! smack :: check_install ( ) { Err ( " " ) ? ; } Backend :: Smack } None => { // If the user did not specify a backend, use the first one that we find. let backend = if klee :: check_install ( ) { Backend :: Klee } else if seahorn :: check_install ( ) { Backend :: Seahorn } else { assert ! ( proptest check_install ( ) ) ; Backend :: Proptest } ; info_at ! ( opt Verbosity Normal " " backend ) ; backend } } ; // To be compatible with `cargo test`, features might be space separated. opt . features = opt . features . iter ( ) . flat_map ( | s | s . split ( ' ' ) ) . map ( String :: from ) . collect :: < Vec < _ > > ( ) ; // Backend specific options. match opt . backend { Backend :: Proptest => { if opt . replay > 0 && ! opt . args . is_empty ( ) { Err ( " " ) ? ; } } Backend :: Seahorn => { if ! opt . args . is_empty ( ) { Err ( " " ) ? ; } if opt . replay != 0 { Err ( " " ) ? ; } opt . features . push ( String :: from ( " " ) ) ; } Backend :: Smack => { if ! opt . args . is_empty ( ) { Err ( " " ) ? ; } if opt . replay != 0 { Err ( " " ) ? ; } opt . features . push ( String :: from ( " " ) ) ; } Backend :: Klee => { opt . features . push ( String :: from ( " " ) ) ; } } // Use the user specified number of jobs, or the number of CPUs. opt . jobs = opt . jobs_arg . unwrap_or ( num_cpus :: get ( ) ) ; Ok ( opt ) }
Parse the command line and make sure it makes sense.
Parse the command line and make sure it makes sense .