Allow testnet command to overwrite files (#1045)

This commit is contained in:
Age Manning
2020-04-23 19:01:16 +10:00
committed by GitHub
parent 91648cc230
commit 6784a8b42a
3 changed files with 22 additions and 9 deletions

View File

@@ -15,11 +15,15 @@ pub fn run<T: EthSpec>(matches: &ArgMatches) -> Result<(), String> {
let deposit_contract_address: Address = parse_required(matches, "deposit-contract-address")?;
let deposit_contract_deploy_block = parse_required(matches, "deposit-contract-deploy-block")?;
let overwrite_files = matches.is_present("force");
if testnet_dir_path.exists() {
return Err(format!(
"{:?} already exists, will not overwrite",
testnet_dir_path
));
if !overwrite_files {
return Err(format!(
"{:?} already exists, will not overwrite. Use --force to overwrite",
testnet_dir_path
));
}
}
let mut spec = T::default_spec();
@@ -57,5 +61,5 @@ pub fn run<T: EthSpec>(matches: &ArgMatches) -> Result<(), String> {
yaml_config: Some(YamlConfig::from_spec::<T>(&spec)),
};
testnet.write_to_file(testnet_dir_path)
testnet.write_to_file(testnet_dir_path, overwrite_files)
}