From 249f1503e6a30a5b7fb58550df9cd9873e988083 Mon Sep 17 00:00:00 2001 From: Falco Hirschenberger Date: Mon, 15 Mar 2021 14:47:02 +0100 Subject: [PATCH] Add more relaxed pallet-name parsing (#8353) Make it possbible to use the pallet's path name, with `-` separator or crate name with `_` separator. fixes #8226 --- substrate/utils/frame/benchmarking-cli/src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/substrate/utils/frame/benchmarking-cli/src/lib.rs b/substrate/utils/frame/benchmarking-cli/src/lib.rs index 19f4596e92..6784b1ecab 100644 --- a/substrate/utils/frame/benchmarking-cli/src/lib.rs +++ b/substrate/utils/frame/benchmarking-cli/src/lib.rs @@ -21,11 +21,17 @@ mod writer; use sc_cli::{ExecutionStrategy, WasmExecutionMethod}; use std::fmt::Debug; +// Add a more relaxed parsing for pallet names by allowing pallet directory names with `-` to be used +// like crate names with `_` +fn parse_pallet_name(pallet: &str) -> String { + pallet.replace("-", "_") +} + /// The `benchmark` command used to benchmark FRAME Pallets. #[derive(Debug, structopt::StructOpt)] pub struct BenchmarkCmd { /// Select a FRAME Pallet to benchmark, or `*` for all (in which case `extrinsic` must be `*`). - #[structopt(short, long)] + #[structopt(short, long, parse(from_str = parse_pallet_name))] pub pallet: String, /// Select an extrinsic inside the pallet to benchmark, or `*` for all.