diff --git a/Cargo.lock b/Cargo.lock index 7009622b1733..89c60b06eec7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,15 +33,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "anstream" version = "0.6.13" @@ -96,17 +87,6 @@ version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -145,7 +125,7 @@ version = "0.48.0" dependencies = [ "anyhow", "cargo_metadata", - "clap 4.5.2", + "clap", "which", ] @@ -187,21 +167,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", -] - [[package]] name = "clap" version = "4.5.2" @@ -221,7 +186,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.0", + "strsim", ] [[package]] @@ -427,15 +392,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "home" version = "0.5.9" @@ -481,7 +437,7 @@ dependencies = [ name = "kani-compiler" version = "0.48.0" dependencies = [ - "clap 4.5.2", + "clap", "cprover_bindings", "home", "itertools", @@ -504,7 +460,7 @@ version = "0.48.0" dependencies = [ "anyhow", "cargo_metadata", - "clap 4.5.2", + "clap", "comfy-table", "console", "glob", @@ -531,7 +487,6 @@ name = "kani-verifier" version = "0.48.0" dependencies = [ "anyhow", - "clap 2.34.0", "home", "os_info", ] @@ -550,7 +505,7 @@ dependencies = [ name = "kani_metadata" version = "0.48.0" dependencies = [ - "clap 4.5.2", + "clap", "cprover_bindings", "serde", "strum 0.26.2", @@ -1095,12 +1050,6 @@ dependencies = [ "serde", ] -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.11.0" @@ -1178,15 +1127,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "1.0.57" @@ -1365,12 +1305,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index c863ffdc1945..8d397f2b0bd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,6 @@ include = ["/src", "/build.rs", "/rust-toolchain.toml", "/LICENSE-*", "/README.m [dependencies] anyhow = "1" home = "0.5" -clap = "2.33.3" os_info = { version = "3", default-features = false } [[bin]] diff --git a/src/lib.rs b/src/lib.rs index 202d46f0e5ac..0015829f61d3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,7 +16,6 @@ mod cmd; mod os_hacks; mod setup; -use clap::{App, Arg, SubCommand}; use std::ffi::OsString; use std::os::unix::prelude::CommandExt; use std::path::{Path, PathBuf}; @@ -60,50 +59,54 @@ enum ArgsResult { /// Parse `args` and decide what to do. fn parse_args(args: Vec) -> ArgsResult { - let matches = App::new("kani") - .subcommand( - SubCommand::with_name("setup") - .arg(Arg::with_name("use-local-bundle").long("use-local-bundle").takes_value(true)) - .arg( - Arg::with_name("use-local-toolchain") - .long("use-local-toolchain") - .takes_value(true), - ), - ) - .subcommand( - SubCommand::with_name("kani").subcommand( - SubCommand::with_name("setup") - .arg( - Arg::with_name("use-local-bundle") - .long("use-local-bundle") - .takes_value(true), - ) - .arg( - Arg::with_name("use-local-toolchain") - .long("use-local-toolchain") - .takes_value(true), - ), - ), - ) - .get_matches_from(args); - - // Default is the behaviour for Kani when cargo-kani/ cargo kani runs on its own and sees that there is no setup done yet - // Explicit is when the user uses the sub-command cargo-kani setup explicitly - if let Some(matches) = matches.subcommand_matches("setup") { - let use_local_toolchain = matches.value_of_os("use-local-toolchain").map(OsString::from); - let use_local_bundle = matches.value_of_os("use-local-bundle").map(OsString::from); - ArgsResult::ExplicitSetup { use_local_bundle, use_local_toolchain } - } else if let Some(matches) = matches.subcommand_matches("kani") { - if let Some(matches) = matches.subcommand_matches("setup") { - let use_local_toolchain = - matches.value_of_os("use-local-toolchain").map(OsString::from); - let use_local_bundle = matches.value_of_os("use-local-bundle").map(OsString::from); - ArgsResult::ExplicitSetup { use_local_bundle, use_local_toolchain } - } else { - ArgsResult::Default + // In an effort to keep our dependencies minimal, we do the bare minimum argument parsing manually. + // `args_ez` makes it easy to do crude arg parsing with match. + let args_ez: Vec> = args.iter().map(|x| x.to_str()).collect(); + // "cargo kani setup" comes in as "cargo-kani kani setup" + // "cargo-kani setup" comes in as "cargo-kani setup" + match &args_ez[..] { + &[_, Some("setup"), Some("--use-local-bundle"), _, Some("--use-local-toolchain"), _] => { + ArgsResult::ExplicitSetup { + use_local_bundle: Some(args[3].clone()), + use_local_toolchain: Some(args[5].clone()), + } + } + &[ + _, + Some("kani"), + Some("setup"), + Some("--use-local-bundle"), + _, + Some("--use-local-toolchain"), + _, + ] => ArgsResult::ExplicitSetup { + use_local_bundle: Some(args[4].clone()), + use_local_toolchain: Some(args[6].clone()), + }, + &[_, Some("setup"), Some("--use-local-bundle"), _] => ArgsResult::ExplicitSetup { + use_local_bundle: Some(args[3].clone()), + use_local_toolchain: None, + }, + &[_, Some("kani"), Some("setup"), Some("--use-local-bundle"), _] => { + ArgsResult::ExplicitSetup { + use_local_bundle: Some(args[4].clone()), + use_local_toolchain: None, + } + } + &[_, Some("setup"), Some("--use-local-toolchain"), _] => ArgsResult::ExplicitSetup { + use_local_bundle: None, + use_local_toolchain: Some(args[3].clone()), + }, + &[_, Some("kani"), Some("setup"), Some("--use-local-toolchain"), _] => { + ArgsResult::ExplicitSetup { + use_local_bundle: None, + use_local_toolchain: Some(args[4].clone()), + } + } + &[_, Some("setup")] | &[_, Some("kani"), Some("setup")] => { + ArgsResult::ExplicitSetup { use_local_bundle: None, use_local_toolchain: None } } - } else { - ArgsResult::Default + _ => ArgsResult::Default, } }