From c63cd11c1aa153cd7c81e109f4aacc6581884c7e Mon Sep 17 00:00:00 2001 From: Enzo Haussecker Date: Sat, 11 Apr 2020 21:20:35 -0700 Subject: [PATCH 1/7] Upgrade Clap to version 3.0 --- Cargo.lock | 81 +++++++++++++++---- src/dfx/Cargo.toml | 2 +- src/dfx/src/commands/bootstrap.rs | 20 ++--- src/dfx/src/commands/build.rs | 8 +- src/dfx/src/commands/cache/delete.rs | 8 +- src/dfx/src/commands/cache/install.rs | 8 +- src/dfx/src/commands/cache/list.rs | 8 +- src/dfx/src/commands/cache/mod.rs | 8 +- src/dfx/src/commands/cache/show.rs | 8 +- src/dfx/src/commands/canister/call.rs | 8 +- src/dfx/src/commands/canister/install.rs | 10 +-- src/dfx/src/commands/canister/mod.rs | 8 +- src/dfx/src/commands/canister/query.rs | 8 +- .../src/commands/canister/request_status.rs | 8 +- src/dfx/src/commands/config.rs | 8 +- src/dfx/src/commands/language_service.rs | 10 +-- src/dfx/src/commands/mod.rs | 10 +-- src/dfx/src/commands/new.rs | 8 +- src/dfx/src/commands/replica.rs | 16 ++-- src/dfx/src/commands/start.rs | 10 +-- src/dfx/src/commands/stop.rs | 8 +- src/dfx/src/commands/upgrade.rs | 8 +- src/dfx/src/main.rs | 12 +-- 23 files changed, 168 insertions(+), 115 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3f74a149d3..fcad0ef0f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -322,7 +322,7 @@ dependencies = [ [[package]] name = "ansi_term" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -584,18 +584,33 @@ dependencies = [ [[package]] name = "clap" -version = "2.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "3.0.0-beta.1" +source = "git+https://github.com/clap-rs/clap?rev=7788268D#7788268d3768810e91a911da0916db0e15105cf0" dependencies = [ - "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "clap_derive 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268D)", + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "clap_derive" +version = "3.0.0-beta.1" +source = "git+https://github.com/clap-rs/clap?rev=7788268D#7788268d3768810e91a911da0916db0e15105cf0" +dependencies = [ + "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-error 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "clicolors-control" version = "1.0.1" @@ -894,7 +909,7 @@ dependencies = [ "actix-web 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268D)", "console 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "delay 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2302,6 +2317,30 @@ dependencies = [ "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "proc-macro-error" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro-error-attr 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "proc-macro-error-attr" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "syn-mid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "proc-macro-hack" version = "0.5.10" @@ -3048,11 +3087,6 @@ name = "string_cache_shared" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "strsim" version = "0.9.2" @@ -3078,6 +3112,16 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syn-mid" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "synstructure" version = "0.10.2" @@ -3610,6 +3654,11 @@ name = "version_check" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "version_check" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "wabt" version = "0.9.2" @@ -3891,7 +3940,7 @@ dependencies = [ "checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" "checksum ahash 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "6f33b5018f120946c1dcf279194f238a9f146725593ead1c08fa47ff22b0b5d3" "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" -"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" "checksum anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "7825f6833612eb2414095684fcf6c635becf3ce97fe48cf6421321e93bfbd53c" "checksum approx 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08abcc3b4e9339e33a3d0a5ed15d84a687350c05689d825e0f6655eef9e76a94" "checksum arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f1a1eca3195b729bbd64e292ef2f5fff6b1c28504fed762ce2b1013dde4d8e92" @@ -3925,7 +3974,8 @@ dependencies = [ "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum cgmath 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "64a4b57c8f4e3a2e9ac07e0f6abc9c24b6fc9e1b54c3478cfb598f3d0023e51c" "checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" -"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +"checksum clap 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268D)" = "" +"checksum clap_derive 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268D)" = "" "checksum clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cmake 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "81fb25b677f8bf1eb325017cb6bb8452f87969db0fedb4f757b297bee78a7c62" @@ -4108,6 +4158,8 @@ dependencies = [ "checksum predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" "checksum pretty 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f60c0d9f6fc88ecdd245d90c1920ff76a430ab34303fc778d33b1d0a4c3bf6d3" "checksum proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" +"checksum proc-macro-error 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7" +"checksum proc-macro-error-attr 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69de" "checksum proc-macro-hack 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "114cdf1f426eb7f550f01af5f53a33c0946156f6814aec939b3bd77e844f9a9d" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afdc77cc74ec70ed262262942ebb7dac3d479e9e5cfa2da1841c0806f6cdabcc" @@ -4185,10 +4237,10 @@ dependencies = [ "checksum string_cache 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "96ccb3a75a3caf2d7f2eb9ada86ec1fbbd4c74ad2bd8dc00a96a0c2f93509ef0" "checksum string_cache_codegen 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0f45ed1b65bf9a4bf2f7b7dc59212d1926e9eaf00fa998988e420fd124467c6" "checksum string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc" -"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum strsim 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "032c03039aae92b350aad2e3779c352e104d919cb192ba2fabbd7b831ce4f0f6" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" "checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" +"checksum syn-mid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum sysinfo 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4b2468c629cffba39c0a4425849ab3cdb03d9dfacba69684609aea04d08ff9" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" @@ -4245,6 +4297,7 @@ dependencies = [ "checksum vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "33dd455d0f96e90a75803cfeb7f948768c08d70a6de9a8d2362461935698bf95" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" +"checksum version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" "checksum wabt 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3c5c5c1286c6e578416982609f47594265f9d489f9b836157d403ad605a46693" "checksum wabt-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "af5d153dc96aad7dc13ab90835b892c69867948112d95299e522d370c4e13a08" "checksum wait-timeout 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" diff --git a/src/dfx/Cargo.toml b/src/dfx/Cargo.toml index 77845f347c..88ccf77634 100644 --- a/src/dfx/Cargo.toml +++ b/src/dfx/Cargo.toml @@ -21,7 +21,7 @@ actix-server = "0.6.1" actix-web = "1.0.8" atty = "0.2.13" base64 = "0.11.0" -clap = "2.33.0" +clap = { git = "https://github.com/clap-rs/clap", rev = "7788268d" } console = "0.7.7" crossbeam = "0.7.3" delay = "0.1.0" diff --git a/src/dfx/src/commands/bootstrap.rs b/src/dfx/src/commands/bootstrap.rs index 4e05d03bee..e30e6da2c1 100644 --- a/src/dfx/src/commands/bootstrap.rs +++ b/src/dfx/src/commands/bootstrap.rs @@ -3,7 +3,7 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::webserver::webserver; -use clap::{App, Arg, ArgMatches, SubCommand}; +use clap::{App, Arg, ArgMatches}; use slog::info; use std::default::Default; use std::fs; @@ -14,8 +14,8 @@ use std::str::FromStr; use url::{ParseError, Url}; /// Constructs a sub-command to run the bootstrap server. -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("bootstrap") +pub fn construct() -> App<'static> { + App::new("bootstrap") .about(UserMessage::BootstrapCommand.to_str()) .arg( Arg::with_name("ip") @@ -51,7 +51,7 @@ pub fn construct() -> App<'static, 'static> { } /// Runs the bootstrap server. -pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult { let logger = env.get_logger(); let config = get_config(env, args)?; @@ -88,7 +88,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { /// Gets the configuration options for the bootstrap server. Each option is checked for correctness /// and otherwise guaranteed to exist. -fn get_config(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { +fn get_config(env: &dyn Environment, args: &ArgMatches) -> DfxResult { let config = get_config_from_file(env); let ip = get_ip(&config, args)?; let port = get_port(&config, args)?; @@ -119,7 +119,7 @@ fn get_config_from_file(env: &dyn Environment) -> ConfigDefaultsBootstrap { /// Gets the IP address that the bootstrap server listens on. First checks if the IP address was /// specified on the command-line using --ip, otherwise checks if the IP address was specified in /// the dfx configuration file, otherise defaults to 127.0.0.1. -fn get_ip(config: &ConfigDefaultsBootstrap, args: &ArgMatches<'_>) -> DfxResult { +fn get_ip(config: &ConfigDefaultsBootstrap, args: &ArgMatches) -> DfxResult { args.value_of("ip") .map(|ip| ip.parse()) .unwrap_or_else(|| { @@ -132,7 +132,7 @@ fn get_ip(config: &ConfigDefaultsBootstrap, args: &ArgMatches<'_>) -> DfxResult< /// Gets the port number that the bootstrap server listens on. First checks if the port number was /// specified on the command-line using --port, otherwise checks if the port number was specified /// in the dfx configuration file, otherise defaults to 8081. -fn get_port(config: &ConfigDefaultsBootstrap, args: &ArgMatches<'_>) -> DfxResult { +fn get_port(config: &ConfigDefaultsBootstrap, args: &ArgMatches) -> DfxResult { args.value_of("port") .map(|port| port.parse()) .unwrap_or_else(|| { @@ -147,7 +147,7 @@ fn get_port(config: &ConfigDefaultsBootstrap, args: &ArgMatches<'_>) -> DfxResul /// dfx configuration file, otherwise defaults to http://127.0.0.1:8080/api. fn get_providers( config: &ConfigDefaultsBootstrap, - args: &ArgMatches<'_>, + args: &ArgMatches, ) -> DfxResult> { args.values_of("providers") .map(|providers| { @@ -178,7 +178,7 @@ fn get_providers( fn get_root( config: &ConfigDefaultsBootstrap, env: &dyn Environment, - args: &ArgMatches<'_>, + args: &ArgMatches, ) -> DfxResult { args.value_of("root") .map(|root| parse_dir(root)) @@ -205,7 +205,7 @@ fn get_root( /// requests to complete. First checks if the timeout was specified on the command-line using /// --timeout, otherwise checks if the timeout was specified in the dfx configuration file, /// otherise defaults to 30. -fn get_timeout(config: &ConfigDefaultsBootstrap, args: &ArgMatches<'_>) -> DfxResult { +fn get_timeout(config: &ConfigDefaultsBootstrap, args: &ArgMatches) -> DfxResult { args.value_of("timeout") .map(|timeout| timeout.parse()) .unwrap_or_else(|| { diff --git a/src/dfx/src/commands/build.rs b/src/dfx/src/commands/build.rs index 5bc27823e4..bac30a8f7a 100644 --- a/src/dfx/src/commands/build.rs +++ b/src/dfx/src/commands/build.rs @@ -4,10 +4,10 @@ use crate::lib::environment::Environment; use crate::lib::error::{BuildErrorKind, DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::models::canister::CanisterPool; -use clap::{App, Arg, ArgMatches, SubCommand}; +use clap::{App, Arg, ArgMatches}; -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("build") +pub fn construct() -> App<'static> { + App::new("build") .about(UserMessage::BuildCanister.to_str()) .arg( Arg::with_name("skip-frontend") @@ -17,7 +17,7 @@ pub fn construct() -> App<'static, 'static> { ) } -pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult { let logger = env.get_logger(); // Read the config. diff --git a/src/dfx/src/commands/cache/delete.rs b/src/dfx/src/commands/cache/delete.rs index cf25df6af8..109ecc9c1e 100644 --- a/src/dfx/src/commands/cache/delete.rs +++ b/src/dfx/src/commands/cache/delete.rs @@ -2,15 +2,15 @@ use crate::config::cache::delete_version; use crate::lib::environment::Environment; use crate::lib::error::DfxResult; use crate::lib::message::UserMessage; -use clap::{App, Arg, ArgMatches, SubCommand}; +use clap::{App, Arg, ArgMatches}; -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("delete") +pub fn construct() -> App<'static> { + App::new("delete") .about(UserMessage::CacheDelete.to_str()) .arg(Arg::with_name("version").takes_value(true)) } -pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult { match args.value_of("version") { Some(v) => delete_version(v).map(|_| {}), _ => env.get_cache().delete(), diff --git a/src/dfx/src/commands/cache/install.rs b/src/dfx/src/commands/cache/install.rs index 8d9b952ab4..a83ce58bea 100644 --- a/src/dfx/src/commands/cache/install.rs +++ b/src/dfx/src/commands/cache/install.rs @@ -1,12 +1,12 @@ use crate::lib::environment::Environment; use crate::lib::error::DfxResult; use crate::lib::message::UserMessage; -use clap::{App, ArgMatches, SubCommand}; +use clap::{App, ArgMatches}; -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("install").about(UserMessage::CacheUnpack.to_str()) +pub fn construct() -> App<'static> { + App::new("install").about(UserMessage::CacheUnpack.to_str()) } -pub fn exec(env: &dyn Environment, _args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, _args: &ArgMatches) -> DfxResult { env.get_cache().force_install() } diff --git a/src/dfx/src/commands/cache/list.rs b/src/dfx/src/commands/cache/list.rs index 4e8344dc46..9a0a553d80 100644 --- a/src/dfx/src/commands/cache/list.rs +++ b/src/dfx/src/commands/cache/list.rs @@ -2,14 +2,14 @@ use crate::config::{cache, dfx_version}; use crate::lib::environment::Environment; use crate::lib::error::DfxResult; use crate::lib::message::UserMessage; -use clap::{App, ArgMatches, SubCommand}; +use clap::{App, ArgMatches}; use std::io::Write; -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("list").about(UserMessage::CacheList.to_str()) +pub fn construct() -> App<'static> { + App::new("list").about(UserMessage::CacheList.to_str()) } -pub fn exec(env: &dyn Environment, _args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, _args: &ArgMatches) -> DfxResult { let mut current_printed = false; let current_version = env.get_version(); let mut all_versions = cache::list_versions()?; diff --git a/src/dfx/src/commands/cache/mod.rs b/src/dfx/src/commands/cache/mod.rs index ae692f25de..873d160a35 100644 --- a/src/dfx/src/commands/cache/mod.rs +++ b/src/dfx/src/commands/cache/mod.rs @@ -2,7 +2,7 @@ use crate::commands::CliCommand; use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; -use clap::{App, ArgMatches, SubCommand}; +use clap::{App, ArgMatches}; mod delete; mod install; @@ -18,13 +18,13 @@ fn builtins() -> Vec { ] } -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("cache") +pub fn construct() -> App<'static> { + App::new("cache") .about(UserMessage::ManageCache.to_str()) .subcommands(builtins().into_iter().map(|x| x.get_subcommand().clone())) } -pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult { let subcommand = args.subcommand(); if let (name, Some(subcommand_args)) = subcommand { diff --git a/src/dfx/src/commands/cache/show.rs b/src/dfx/src/commands/cache/show.rs index 9132b20e02..d8eec98d96 100644 --- a/src/dfx/src/commands/cache/show.rs +++ b/src/dfx/src/commands/cache/show.rs @@ -2,13 +2,13 @@ use crate::config::cache; use crate::lib::environment::Environment; use crate::lib::error::DfxResult; use crate::lib::message::UserMessage; -use clap::{App, ArgMatches, SubCommand}; +use clap::{App, ArgMatches}; -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("show").about(UserMessage::CacheShow.to_str()) +pub fn construct() -> App<'static> { + App::new("show").about(UserMessage::CacheShow.to_str()) } -pub fn exec(env: &dyn Environment, _args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, _args: &ArgMatches) -> DfxResult { let v = format!("{}", env.get_version()); println!("{}", cache::get_bin_cache(&v)?.as_path().display()); Ok(()) diff --git a/src/dfx/src/commands/canister/call.rs b/src/dfx/src/commands/canister/call.rs index 03545e1cf4..36ab1a9377 100644 --- a/src/dfx/src/commands/canister/call.rs +++ b/src/dfx/src/commands/canister/call.rs @@ -4,11 +4,11 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::util::{blob_from_arguments, load_idl_file, print_idl_blob}; -use clap::{App, Arg, ArgMatches, SubCommand}; +use clap::{App, Arg, ArgMatches}; use tokio::runtime::Runtime; -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("call") +pub fn construct() -> App<'static> { + App::new("call") .about(UserMessage::CallCanister.to_str()) .arg( Arg::with_name("canister_name") @@ -58,7 +58,7 @@ pub fn construct() -> App<'static, 'static> { ) } -pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult { let config = env .get_config() .ok_or(DfxError::CommandMustBeRunInAProject)?; diff --git a/src/dfx/src/commands/canister/install.rs b/src/dfx/src/commands/canister/install.rs index 019de097b4..f2656d5285 100644 --- a/src/dfx/src/commands/canister/install.rs +++ b/src/dfx/src/commands/canister/install.rs @@ -4,14 +4,14 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; -use clap::{App, Arg, ArgMatches, SubCommand}; +use clap::{App, Arg, ArgMatches}; use ic_http_agent::{Agent, Blob, CanisterAttributes, ComputeAllocation, RequestId}; use slog::info; use std::convert::TryInto; use tokio::runtime::Runtime; -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("install") +pub fn construct() -> App<'static> { + App::new("install") .about(UserMessage::InstallCanister.to_str()) .arg( Arg::with_name("canister_name") @@ -37,7 +37,7 @@ pub fn construct() -> App<'static, 'static> { Arg::with_name("compute-allocation") .help(UserMessage::InstallComputeAllocation.to_str()) .long("compute-allocation") - .short("c") + .short('c') .takes_value(true) .default_value("0") .validator(compute_allocation_validator), @@ -85,7 +85,7 @@ fn compute_allocation_validator(compute_allocation: String) -> Result<(), String Err("Must be a percent between 0 and 100".to_string()) } -pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult { let log = env.get_logger(); let config = env .get_config() diff --git a/src/dfx/src/commands/canister/mod.rs b/src/dfx/src/commands/canister/mod.rs index 59d4a8ca5d..71ee2ac103 100644 --- a/src/dfx/src/commands/canister/mod.rs +++ b/src/dfx/src/commands/canister/mod.rs @@ -2,7 +2,7 @@ use crate::commands::CliCommand; use crate::lib::environment::{AgentEnvironment, Environment}; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; -use clap::{App, Arg, ArgMatches, SubCommand}; +use clap::{App, Arg, ArgMatches}; use delay::Delay; use std::time::Duration; @@ -30,8 +30,8 @@ fn builtins() -> Vec { ] } -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("canister") +pub fn construct() -> App<'static> { + App::new("canister") .about(UserMessage::ManageCanister.to_str()) .arg( Arg::with_name("client") @@ -47,7 +47,7 @@ pub fn construct() -> App<'static, 'static> { .subcommands(builtins().into_iter().map(|x| x.get_subcommand().clone())) } -pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult { let subcommand = args.subcommand(); // Need storage for ClientEnvironment ownership. diff --git a/src/dfx/src/commands/canister/query.rs b/src/dfx/src/commands/canister/query.rs index 60ad72f221..cbfd475caa 100644 --- a/src/dfx/src/commands/canister/query.rs +++ b/src/dfx/src/commands/canister/query.rs @@ -3,11 +3,11 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::util::{blob_from_arguments, print_idl_blob}; -use clap::{App, Arg, ArgMatches, SubCommand}; +use clap::{App, Arg, ArgMatches}; use tokio::runtime::Runtime; -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("query") +pub fn construct() -> App<'static> { + App::new("query") .about(UserMessage::QueryCanister.to_str()) .arg( Arg::with_name("canister_name") @@ -35,7 +35,7 @@ pub fn construct() -> App<'static, 'static> { ) } -pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult { let config = env .get_config() .ok_or(DfxError::CommandMustBeRunInAProject)?; diff --git a/src/dfx/src/commands/canister/request_status.rs b/src/dfx/src/commands/canister/request_status.rs index 1f8ba86c9a..67595fb01a 100644 --- a/src/dfx/src/commands/canister/request_status.rs +++ b/src/dfx/src/commands/canister/request_status.rs @@ -4,13 +4,13 @@ use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::util::clap::validators; use crate::util::print_idl_blob; -use clap::{App, Arg, ArgMatches, SubCommand}; +use clap::{App, Arg, ArgMatches}; use ic_http_agent::RequestId; use std::str::FromStr; use tokio::runtime::Runtime; -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("request-status") +pub fn construct() -> App<'static> { + App::new("request-status") .about(UserMessage::RequestCallStatus.to_str()) .arg( Arg::with_name("request_id") @@ -21,7 +21,7 @@ pub fn construct() -> App<'static, 'static> { ) } -pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult { let request_id = RequestId::from_str( &args .value_of("request_id") diff --git a/src/dfx/src/commands/config.rs b/src/dfx/src/commands/config.rs index 8de258deff..667732faa2 100644 --- a/src/dfx/src/commands/config.rs +++ b/src/dfx/src/commands/config.rs @@ -2,11 +2,11 @@ use crate::config::dfinity::Config; use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; -use clap::{App, Arg, ArgMatches, SubCommand}; +use clap::{App, Arg, ArgMatches}; use serde_json::value::Value; -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("config") +pub fn construct() -> App<'static> { + App::new("config") .about(UserMessage::ConfigureOptions.to_str()) .arg(Arg::with_name("config_path").help(UserMessage::OptionName.to_str())) .arg(Arg::with_name("value").help(UserMessage::OptionValue.to_str())) @@ -20,7 +20,7 @@ pub fn construct() -> App<'static, 'static> { ) } -pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult { // Cannot use the `env` variable as we need a mutable copy. let mut config: Config = env .get_config() diff --git a/src/dfx/src/commands/language_service.rs b/src/dfx/src/commands/language_service.rs index 68a7a2d96d..190e300500 100644 --- a/src/dfx/src/commands/language_service.rs +++ b/src/dfx/src/commands/language_service.rs @@ -3,14 +3,14 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use atty; -use clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; +use clap::{App, AppSettings, Arg, ArgMatches}; use std::process::Stdio; const CANISTER_ARG: &str = "canister"; const FORCE_TTY: &str = "force-tty"; -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("_language-service") +pub fn construct() -> App<'static> { + App::new("_language-service") .setting(AppSettings::Hidden) // Hide it from help menus as it shouldn't be used by users. .about(UserMessage::StartLanguageService.to_str()) .arg(Arg::with_name(CANISTER_ARG).help(UserMessage::CanisterName.to_str())) @@ -24,7 +24,7 @@ pub fn construct() -> App<'static, 'static> { // Don't read anything from stdin or output anything to stdout while this function is being // executed or LSP will become very unhappy -pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult { let force_tty = args.is_present(FORCE_TTY); // Are we being run from a terminal? That's most likely not what we want if atty::is(atty::Stream::Stdout) && !force_tty { @@ -37,7 +37,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { } } -fn get_main_path(config: &ConfigInterface, args: &ArgMatches<'_>) -> Result { +fn get_main_path(config: &ConfigInterface, args: &ArgMatches) -> Result { // TODO try and point at the actual dfx.json path let dfx_json = CONFIG_FILE_NAME; diff --git a/src/dfx/src/commands/mod.rs b/src/dfx/src/commands/mod.rs index 3b2a83be21..d48b7fd32a 100644 --- a/src/dfx/src/commands/mod.rs +++ b/src/dfx/src/commands/mod.rs @@ -14,26 +14,26 @@ mod start; mod stop; mod upgrade; -pub type CliExecFn = fn(&dyn Environment, &ArgMatches<'_>) -> DfxResult; +pub type CliExecFn = fn(&dyn Environment, &ArgMatches) -> DfxResult; pub struct CliCommand { - subcommand: clap::App<'static, 'static>, + subcommand: clap::App<'static>, executor: CliExecFn, } impl CliCommand { - pub fn new(subcommand: clap::App<'static, 'static>, executor: CliExecFn) -> CliCommand { + pub fn new(subcommand: clap::App<'static>, executor: CliExecFn) -> CliCommand { CliCommand { subcommand, executor, } } - pub fn get_subcommand(&self) -> &clap::App<'static, 'static> { + pub fn get_subcommand(&self) -> &clap::App<'static> { &self.subcommand } pub fn get_name(&self) -> &str { self.subcommand.get_name() } - pub fn execute(self: &CliCommand, env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { + pub fn execute(self: &CliCommand, env: &dyn Environment, args: &ArgMatches) -> DfxResult { (self.executor)(env, args) } } diff --git a/src/dfx/src/commands/new.rs b/src/dfx/src/commands/new.rs index 3d2bc638bd..696032d9ca 100644 --- a/src/dfx/src/commands/new.rs +++ b/src/dfx/src/commands/new.rs @@ -4,7 +4,7 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::util::assets; -use clap::{App, Arg, ArgMatches, SubCommand}; +use clap::{App, Arg, ArgMatches}; use console::{style, Style}; use indicatif::HumanBytes; use lazy_static::lazy_static; @@ -62,8 +62,8 @@ pub fn project_name_validator(name: String) -> Result<(), String> { } } -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("new") +pub fn construct() -> App<'static> { + App::new("new") .about(UserMessage::CreateProject.to_str()) .arg( Arg::with_name(PROJECT_NAME) @@ -313,7 +313,7 @@ fn scaffold_frontend_code( Ok(()) } -pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult { let log = env.get_logger(); let dry_run = args.is_present(DRY_RUN); let project_name_path = args diff --git a/src/dfx/src/commands/replica.rs b/src/dfx/src/commands/replica.rs index b19dd7abea..1986f18748 100644 --- a/src/dfx/src/commands/replica.rs +++ b/src/dfx/src/commands/replica.rs @@ -6,12 +6,12 @@ use crate::lib::message::UserMessage; use crate::lib::replica_config::{HttpHandlerConfig, ReplicaConfig, SchedulerConfig}; use actix::Actor; -use clap::{App, Arg, ArgMatches, SubCommand}; +use clap::{App, Arg, ArgMatches}; use std::default::Default; /// Constructs a sub-command to run the Internet Computer replica. -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("replica") +pub fn construct() -> App<'static> { + App::new("replica") .about(UserMessage::Replica.to_str()) .arg( Arg::with_name("message-gas-limit") @@ -36,7 +36,7 @@ pub fn construct() -> App<'static, 'static> { } /// Gets the configuration options for the Internet Computer replica. -fn get_config(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { +fn get_config(env: &dyn Environment, args: &ArgMatches) -> DfxResult { let config = get_config_from_file(env); let port = get_port(&config, args)?; let mut http_handler: HttpHandlerConfig = Default::default(); @@ -71,7 +71,7 @@ fn get_config_from_file(env: &dyn Environment) -> ConfigDefaultsReplica { /// Gets the port number that the Internet Computer replica listens on. First checks if the port /// number was specified on the command-line using --port, otherwise checks if the port number was /// specified in the dfx configuration file, otherise defaults to 8080. -fn get_port(config: &ConfigDefaultsReplica, args: &ArgMatches<'_>) -> DfxResult { +fn get_port(config: &ConfigDefaultsReplica, args: &ArgMatches) -> DfxResult { args.value_of("port") .map(|port| port.parse()) .unwrap_or_else(|| { @@ -84,7 +84,7 @@ fn get_port(config: &ConfigDefaultsReplica, args: &ArgMatches<'_>) -> DfxResult< /// Gets the maximum amount of gas a single message can consume. First checks if the gas limit was /// specified on the command-line using --message-gas-limit, otherwise checks if the gas limit was /// specified in the dfx configuration file, otherise defaults to 5368709120. -fn get_message_gas_limit(config: &ConfigDefaultsReplica, args: &ArgMatches<'_>) -> DfxResult { +fn get_message_gas_limit(config: &ConfigDefaultsReplica, args: &ArgMatches) -> DfxResult { args.value_of("message-gas-limit") .map(|limit| limit.parse()) .unwrap_or_else(|| { @@ -97,7 +97,7 @@ fn get_message_gas_limit(config: &ConfigDefaultsReplica, args: &ArgMatches<'_>) /// Gets the maximum amount of gas a single round can consume. First checks if the gas limit was /// specified on the command-line using --round-gas-limit, otherwise checks if the gas limit was /// specified in the dfx configuration file, otherise defaults to 26843545600. -fn get_round_gas_limit(config: &ConfigDefaultsReplica, args: &ArgMatches<'_>) -> DfxResult { +fn get_round_gas_limit(config: &ConfigDefaultsReplica, args: &ArgMatches) -> DfxResult { args.value_of("round-gas-limit") .map(|limit| limit.parse()) .unwrap_or_else(|| { @@ -110,7 +110,7 @@ fn get_round_gas_limit(config: &ConfigDefaultsReplica, args: &ArgMatches<'_>) -> /// Start the Internet Computer locally. Spawns a proxy to forward and /// manage browser requests. Responsible for running the network (one /// replica at the moment) and the proxy. -pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult { let replica_pathbuf = env.get_cache().get_binary_command_path("replica")?; let system = actix::System::new("dfx-replica"); diff --git a/src/dfx/src/commands/start.rs b/src/dfx/src/commands/start.rs index 12b2a6c1cb..93e743a06e 100644 --- a/src/dfx/src/commands/start.rs +++ b/src/dfx/src/commands/start.rs @@ -7,7 +7,7 @@ use crate::lib::proxy::{CoordinateProxy, ProxyConfig}; use crate::lib::proxy_process::spawn_and_update_proxy; use crate::lib::replica_config::ReplicaConfig; -use clap::{App, Arg, ArgMatches, SubCommand}; +use clap::{App, Arg, ArgMatches}; use crossbeam::channel::{Receiver, Sender}; use crossbeam::unbounded; use futures::future::Future; @@ -24,8 +24,8 @@ use tokio::runtime::Runtime; /// Provide necessary arguments to start the Internet Computer /// locally. See `exec` for further information. -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("start") +pub fn construct() -> App<'static> { + App::new("start") .about(UserMessage::StartNode.to_str()) .arg( Arg::with_name("host") @@ -64,7 +64,7 @@ fn ping_and_wait(frontend_url: &str) -> DfxResult { /// Start the Internet Computer locally. Spawns a proxy to forward and /// manage browser requests. Responsible for running the network (one /// replica at the moment) and the proxy. -pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult { let config = env .get_config() .ok_or(DfxError::CommandMustBeRunInAProject)?; @@ -264,7 +264,7 @@ fn send_background() -> DfxResult<()> { Ok(()) } -fn frontend_address(args: &ArgMatches<'_>, config: &Config) -> DfxResult<(String, SocketAddr)> { +fn frontend_address(args: &ArgMatches, config: &Config) -> DfxResult<(String, SocketAddr)> { let address_and_port = args .value_of("host") .and_then(|host| Option::from(host.parse())) diff --git a/src/dfx/src/commands/stop.rs b/src/dfx/src/commands/stop.rs index f6e93cf629..34b88e27ed 100644 --- a/src/dfx/src/commands/stop.rs +++ b/src/dfx/src/commands/stop.rs @@ -1,11 +1,11 @@ use crate::lib::environment::Environment; use crate::lib::error::DfxResult; use crate::lib::message::UserMessage; -use clap::{App, ArgMatches, SubCommand}; +use clap::{App, ArgMatches}; use sysinfo::{Pid, Process, ProcessExt, Signal, System, SystemExt}; -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("stop").about(UserMessage::StopNode.to_str()) +pub fn construct() -> App<'static> { + App::new("stop").about(UserMessage::StopNode.to_str()) } fn list_all_descendants(pid: Pid) -> Vec { @@ -35,7 +35,7 @@ fn kill_all(pid: Pid) -> DfxResult { Ok(()) } -pub fn exec(env: &dyn Environment, _args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, _args: &ArgMatches) -> DfxResult { let pid_file_path = env.get_temp_dir().join("pid"); if pid_file_path.exists() { // Read and verify it's not running. If it is just return. diff --git a/src/dfx/src/commands/upgrade.rs b/src/dfx/src/commands/upgrade.rs index 7ebd801e4d..dc8705da73 100644 --- a/src/dfx/src/commands/upgrade.rs +++ b/src/dfx/src/commands/upgrade.rs @@ -1,6 +1,6 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; -use clap::{App, Arg, ArgMatches, SubCommand}; +use clap::{App, Arg, ArgMatches}; use indicatif::{ProgressBar, ProgressDrawTarget}; use libflate::gzip::Decoder; use semver::Version; @@ -8,8 +8,8 @@ use serde::{Deserialize, Deserializer}; use std::{collections::BTreeMap, env, fs, os::unix::fs::PermissionsExt}; use tar::Archive; -pub fn construct() -> App<'static, 'static> { - SubCommand::with_name("upgrade") +pub fn construct() -> App<'static> { + App::new("upgrade") .about("Upgrade DFX.") .arg( Arg::with_name("current-version") @@ -154,7 +154,7 @@ fn get_latest_release(release_root: &str, version: &Version, arch: &str) -> DfxR Ok(()) } -pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { +pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult { // Find OS architecture. let os_arch = match std::env::consts::OS { "linux" => "x86_64-linux", diff --git a/src/dfx/src/main.rs b/src/dfx/src/main.rs index f006d44b58..141008aa6e 100644 --- a/src/dfx/src/main.rs +++ b/src/dfx/src/main.rs @@ -14,7 +14,7 @@ mod config; mod lib; mod util; -fn cli(_: &impl Environment) -> App<'_, '_> { +fn cli(_: &impl Environment) -> App<'_> { App::new("dfx") .about("The DFINITY Executor.") .version(dfx_version_str()) @@ -22,13 +22,13 @@ fn cli(_: &impl Environment) -> App<'_, '_> { .arg( Arg::with_name("verbose") .long("verbose") - .short("v") + .short('v') .multiple(true), ) .arg( Arg::with_name("quiet") .long("quiet") - .short("q") + .short('q') .multiple(true), ) .arg( @@ -51,7 +51,7 @@ fn cli(_: &impl Environment) -> App<'_, '_> { ) } -fn exec(env: &impl Environment, args: &clap::ArgMatches<'_>, cli: &App<'_, '_>) -> DfxResult { +fn exec(env: &impl Environment, args: &clap::ArgMatches, cli: &mut App<'_>) -> DfxResult { let (name, subcommand_args) = match args.subcommand() { (name, Some(args)) => (name, args), _ => { @@ -126,7 +126,7 @@ fn maybe_redirect_dfx(env: &impl Environment) -> Option<()> { /// Setup a logger with the proper configuration, based on arguments. /// Returns a topple of whether or not to have a progress bar, and a logger. -fn setup_logging(matches: &ArgMatches<'_>) -> (bool, slog::Logger) { +fn setup_logging(matches: &ArgMatches) -> (bool, slog::Logger) { // Create a logger with our argument matches. let level = matches.occurrences_of("verbose") as i64 - matches.occurrences_of("quiet") as i64; @@ -164,7 +164,7 @@ fn main() { env.get_logger(), "Trace mode enabled. Lots of logs coming up." ); - exec(&env, &matches, &(cli(&env))) + exec(&env, &matches, &mut cli(&env)) } Err(e) => Err(e), } From 3a0ecf4721082e81263c722eb60ad1e608de76a9 Mon Sep 17 00:00:00 2001 From: Enzo Haussecker Date: Sat, 11 Apr 2020 22:41:35 -0700 Subject: [PATCH 2/7] Use verbose revision --- Cargo.lock | 12 ++++++------ src/dfx/Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fcad0ef0f5..fefa2db4a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -585,12 +585,12 @@ dependencies = [ [[package]] name = "clap" version = "3.0.0-beta.1" -source = "git+https://github.com/clap-rs/clap?rev=7788268D#7788268d3768810e91a911da0916db0e15105cf0" +source = "git+https://github.com/clap-rs/clap?rev=7788268d#7788268d3768810e91a911da0916db0e15105cf0" dependencies = [ "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "clap_derive 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268D)", + "clap_derive 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268d)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -602,7 +602,7 @@ dependencies = [ [[package]] name = "clap_derive" version = "3.0.0-beta.1" -source = "git+https://github.com/clap-rs/clap?rev=7788268D#7788268d3768810e91a911da0916db0e15105cf0" +source = "git+https://github.com/clap-rs/clap?rev=7788268d#7788268d3768810e91a911da0916db0e15105cf0" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro-error 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -909,7 +909,7 @@ dependencies = [ "actix-web 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268D)", + "clap 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268d)", "console 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "delay 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3974,8 +3974,8 @@ dependencies = [ "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum cgmath 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "64a4b57c8f4e3a2e9ac07e0f6abc9c24b6fc9e1b54c3478cfb598f3d0023e51c" "checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" -"checksum clap 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268D)" = "" -"checksum clap_derive 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268D)" = "" +"checksum clap 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268d)" = "" +"checksum clap_derive 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268d)" = "" "checksum clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cmake 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "81fb25b677f8bf1eb325017cb6bb8452f87969db0fedb4f757b297bee78a7c62" diff --git a/src/dfx/Cargo.toml b/src/dfx/Cargo.toml index 88ccf77634..d4a1401322 100644 --- a/src/dfx/Cargo.toml +++ b/src/dfx/Cargo.toml @@ -21,7 +21,7 @@ actix-server = "0.6.1" actix-web = "1.0.8" atty = "0.2.13" base64 = "0.11.0" -clap = { git = "https://github.com/clap-rs/clap", rev = "7788268d" } +clap = { git = "https://github.com/clap-rs/clap", rev = "7788268d3768810e91a911da0916db0e15105cf0" } console = "0.7.7" crossbeam = "0.7.3" delay = "0.1.0" From 4895436953b3fa4ad25120f097354ee31a887f7e Mon Sep 17 00:00:00 2001 From: Enzo Haussecker Date: Sat, 11 Apr 2020 23:36:01 -0700 Subject: [PATCH 3/7] Update Cargo lock --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fefa2db4a2..249004824c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -585,12 +585,12 @@ dependencies = [ [[package]] name = "clap" version = "3.0.0-beta.1" -source = "git+https://github.com/clap-rs/clap?rev=7788268d#7788268d3768810e91a911da0916db0e15105cf0" +source = "git+https://github.com/clap-rs/clap?rev=7788268d3768810e91a911da0916db0e15105cf0#7788268d3768810e91a911da0916db0e15105cf0" dependencies = [ "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "clap_derive 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268d)", + "clap_derive 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268d3768810e91a911da0916db0e15105cf0)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -602,7 +602,7 @@ dependencies = [ [[package]] name = "clap_derive" version = "3.0.0-beta.1" -source = "git+https://github.com/clap-rs/clap?rev=7788268d#7788268d3768810e91a911da0916db0e15105cf0" +source = "git+https://github.com/clap-rs/clap?rev=7788268d3768810e91a911da0916db0e15105cf0#7788268d3768810e91a911da0916db0e15105cf0" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro-error 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -909,7 +909,7 @@ dependencies = [ "actix-web 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268d)", + "clap 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268d3768810e91a911da0916db0e15105cf0)", "console 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "delay 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3974,8 +3974,8 @@ dependencies = [ "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum cgmath 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "64a4b57c8f4e3a2e9ac07e0f6abc9c24b6fc9e1b54c3478cfb598f3d0023e51c" "checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" -"checksum clap 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268d)" = "" -"checksum clap_derive 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268d)" = "" +"checksum clap 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268d3768810e91a911da0916db0e15105cf0)" = "" +"checksum clap_derive 3.0.0-beta.1 (git+https://github.com/clap-rs/clap?rev=7788268d3768810e91a911da0916db0e15105cf0)" = "" "checksum clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cmake 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "81fb25b677f8bf1eb325017cb6bb8452f87969db0fedb4f757b297bee78a7c62" From e9bf93034015aeed896c5703fe78b9455c011b6d Mon Sep 17 00:00:00 2001 From: Enzo Haussecker Date: Sun, 12 Apr 2020 12:45:48 -0700 Subject: [PATCH 4/7] Change regex in e2e test --- e2e/bats/install.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/bats/install.bash b/e2e/bats/install.bash index ec489f0c10..978eac883c 100644 --- a/e2e/bats/install.bash +++ b/e2e/bats/install.bash @@ -18,5 +18,5 @@ teardown() { @test "install fails if no argument is provided" { assert_command_fail dfx canister install assert_match "required arguments were not provided" - assert_match "--all" + assert_match "" } From 4d808d40bfc3c28651d250b80d6bb27a8d521ccb Mon Sep 17 00:00:00 2001 From: Enzo Haussecker Date: Sun, 12 Apr 2020 17:00:10 -0700 Subject: [PATCH 5/7] Trivial format fix --- src/dfx/src/commands/bootstrap.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/dfx/src/commands/bootstrap.rs b/src/dfx/src/commands/bootstrap.rs index e30e6da2c1..de2335c5dd 100644 --- a/src/dfx/src/commands/bootstrap.rs +++ b/src/dfx/src/commands/bootstrap.rs @@ -145,10 +145,7 @@ fn get_port(config: &ConfigDefaultsBootstrap, args: &ArgMatches) -> DfxResult DfxResult> { +fn get_providers(config: &ConfigDefaultsBootstrap, args: &ArgMatches) -> DfxResult> { args.values_of("providers") .map(|providers| { providers From 5509105497a827c452f2b6b0172627267f1f6bac Mon Sep 17 00:00:00 2001 From: Enzo Haussecker Date: Tue, 14 Apr 2020 21:23:46 -0700 Subject: [PATCH 6/7] Add clap repo to nix sources --- nix/sources.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nix/sources.json b/nix/sources.json index 4ab60424ff..6d50fb1e82 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -25,6 +25,12 @@ "url": "https://github.com/ztombol/bats-support/archive/24a72e14349690bcbf7c151b9d2d1cdd32d36eb1.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, + "clap": { + "ref": "master", + "repo": "https://github.com/clap-rs/clap", + "rev": "7788268d3768810e91a911da0916db0e15105cf0", + "type": "git" + }, "common": { "ref": "master", "repo": "ssh://git@github.com/dfinity-lab/common", From 6e7078aa48db611628a3123b2bf3b8f4c4d7e8f9 Mon Sep 17 00:00:00 2001 From: Enzo Haussecker Date: Thu, 23 Apr 2020 10:55:29 -0700 Subject: [PATCH 7/7] Update Nix sources --- nix/sources.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/sources.json b/nix/sources.json index 6d50fb1e82..7506591def 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -27,7 +27,7 @@ }, "clap": { "ref": "master", - "repo": "https://github.com/clap-rs/clap", + "repo": "ssh://git@github.com/dfinity-lab/clap", "rev": "7788268d3768810e91a911da0916db0e15105cf0", "type": "git" },