use clap3 instead of structopt (#10632)

* use clap3 instead of structopt

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* format

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* update ss58-registry and revert some nits

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Fix clippy and doc

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* update clap to 3.0.7

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Apply review suggestions

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* remove useless option long name

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* cargo fmt

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
This commit is contained in:
Qinxuan Chen
2022-01-25 00:28:46 +08:00
committed by GitHub
parent d1ff02d31e
commit e327b734bc
66 changed files with 660 additions and 768 deletions
@@ -9,7 +9,7 @@ license = "GPL-3.0"
toml = "0.4"
tar = "0.4"
glob = "0.2"
structopt = "0.3"
clap = { version = "3.0", features = ["derive"] }
tempfile = "3"
fs_extra = "1"
git2 = "0.8"
@@ -1,4 +1,4 @@
use structopt::StructOpt;
use clap::Parser;
use std::{
collections::HashMap,
@@ -26,13 +26,13 @@ const SUBSTRATE_GIT_URL: &str = "https://github.com/paritytech/substrate.git";
type CargoToml = HashMap<String, toml::Value>;
#[derive(StructOpt)]
#[derive(Parser)]
struct Options {
/// The path to the `node-template` source.
#[structopt(parse(from_os_str))]
#[clap(parse(from_os_str))]
node_template: PathBuf,
/// The path where to output the generated `tar.gz` file.
#[structopt(parse(from_os_str))]
#[clap(parse(from_os_str))]
output: PathBuf,
}
@@ -209,7 +209,7 @@ fn build_and_test(path: &Path, cargo_tomls: &[PathBuf]) {
}
fn main() {
let options = Options::from_args();
let options = Options::parse();
let build_dir = tempfile::tempdir().expect("Creates temp build dir");
@@ -261,8 +261,7 @@ fn main() {
// adding root rustfmt to node template build path
let node_template_rustfmt_toml_path = node_template_path.join("rustfmt.toml");
let root_rustfmt_toml =
&options.node_template.join("../../rustfmt.toml");
let root_rustfmt_toml = &options.node_template.join("../../rustfmt.toml");
if root_rustfmt_toml.exists() {
fs::copy(&root_rustfmt_toml, &node_template_rustfmt_toml_path)
.expect("Copying rustfmt.toml.");