From bc478e4e56a1be415e37389be7ef38db18912673 Mon Sep 17 00:00:00 2001 From: Seemant Aggarwal <seemant.aggarwal@parity.io> Date: Sat, 1 Mar 2025 10:59:38 +0530 Subject: [PATCH] cargo +nightly fmt --- cumulus/polkadot-omni-node/lib/src/cli.rs | 5 +- cumulus/polkadot-omni-node/lib/src/command.rs | 3 +- .../cli/src/commands/export_chain_spec_cmd.rs | 47 +++++++++---------- substrate/client/cli/src/commands/mod.rs | 7 +-- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/cumulus/polkadot-omni-node/lib/src/cli.rs b/cumulus/polkadot-omni-node/lib/src/cli.rs index 564ee2a4ba6..aefc9d249c0 100644 --- a/cumulus/polkadot-omni-node/lib/src/cli.rs +++ b/cumulus/polkadot-omni-node/lib/src/cli.rs @@ -26,7 +26,10 @@ use crate::{ use chain_spec_builder::ChainSpecBuilder; use clap::{Command, CommandFactory, FromArgMatches}; use sc_chain_spec::ChainSpec; -use sc_cli::{CliConfiguration, DefaultConfigurationValues, ExportChainSpecCmd, ImportParams, KeystoreParams, NetworkParams, RpcEndpoint, SharedParams, SubstrateCli}; +use sc_cli::{ + CliConfiguration, DefaultConfigurationValues, ExportChainSpecCmd, ImportParams, KeystoreParams, + NetworkParams, RpcEndpoint, SharedParams, SubstrateCli, +}; use sc_service::{config::PrometheusConfig, BasePath}; use std::{fmt::Debug, marker::PhantomData, path::PathBuf}; /// Trait that can be used to customize some of the customer-facing info related to the node binary diff --git a/cumulus/polkadot-omni-node/lib/src/command.rs b/cumulus/polkadot-omni-node/lib/src/command.rs index 6f259f7a29b..f552822e197 100644 --- a/cumulus/polkadot-omni-node/lib/src/command.rs +++ b/cumulus/polkadot-omni-node/lib/src/command.rs @@ -169,8 +169,7 @@ pub fn run<CliConfig: crate::cli::CliConfig>(cmd_config: RunConfig) -> Result<() }, Some(Subcommand::ExportChainSpec(cmd)) => { // Directly load the embedded chain spec using the CLI’s load_spec method. - let spec = cli.load_spec(&cmd.chain) - .map_err(|err| format!("{}", err))?; + let spec = cli.load_spec(&cmd.chain).map_err(|err| format!("{}", err))?; cmd.run(spec) }, diff --git a/substrate/client/cli/src/commands/export_chain_spec_cmd.rs b/substrate/client/cli/src/commands/export_chain_spec_cmd.rs index ec523debead..e90331060b0 100644 --- a/substrate/client/cli/src/commands/export_chain_spec_cmd.rs +++ b/substrate/client/cli/src/commands/export_chain_spec_cmd.rs @@ -19,9 +19,9 @@ use clap::Parser; use sc_service::{chain_ops, ChainSpec}; use std::{ - fs, - io::{self, Write}, - path::PathBuf, + fs, + io::{self, Write}, + path::PathBuf, }; use crate::error::{Error, Result}; @@ -33,31 +33,28 @@ use crate::error::{Error, Result}; /// is not provided, the JSON is printed to stdout. #[derive(Debug, Clone, Parser)] pub struct ExportChainSpecCmd { - /// The chain spec identifier to export. - #[arg(long, default_value = "local")] - pub chain: String, + /// The chain spec identifier to export. + #[arg(long, default_value = "local")] + pub chain: String, - /// Output file path. If omitted, prints to stdout. - #[arg(long)] - pub output: Option<PathBuf>, + /// Output file path. If omitted, prints to stdout. + #[arg(long)] + pub output: Option<PathBuf>, - /// Export in raw genesis storage format. - #[arg(long)] - pub raw: bool, + /// Export in raw genesis storage format. + #[arg(long)] + pub raw: bool, } impl ExportChainSpecCmd { - pub fn run(&self, spec: Box<dyn ChainSpec>) -> Result<()> { - let json = chain_ops::build_spec(&*spec, self.raw) - .map_err(|e| format!("{}", e))?; - if let Some(ref path) = self.output { - fs::write(path, json).map_err(|e| format!("{}", e))?; - eprintln!("Exported chain spec to {}", path.display()); - } else { - io::stdout() - .write_all(json.as_bytes()) - .map_err(|e| format!("{}", e))?; - } - Ok(()) - } + pub fn run(&self, spec: Box<dyn ChainSpec>) -> Result<()> { + let json = chain_ops::build_spec(&*spec, self.raw).map_err(|e| format!("{}", e))?; + if let Some(ref path) = self.output { + fs::write(path, json).map_err(|e| format!("{}", e))?; + eprintln!("Exported chain spec to {}", path.display()); + } else { + io::stdout().write_all(json.as_bytes()).map_err(|e| format!("{}", e))?; + } + Ok(()) + } } diff --git a/substrate/client/cli/src/commands/mod.rs b/substrate/client/cli/src/commands/mod.rs index 55b2d51aace..b63fb1d9042 100644 --- a/substrate/client/cli/src/commands/mod.rs +++ b/substrate/client/cli/src/commands/mod.rs @@ -22,6 +22,7 @@ mod build_spec_cmd; mod chain_info_cmd; mod check_block_cmd; mod export_blocks_cmd; +mod export_chain_spec_cmd; mod export_state_cmd; mod generate; mod generate_node_key; @@ -38,13 +39,13 @@ mod test; pub mod utils; mod vanity; mod verify; -mod export_chain_spec_cmd; pub use self::{ build_spec_cmd::BuildSpecCmd, chain_info_cmd::ChainInfoCmd, check_block_cmd::CheckBlockCmd, - export_blocks_cmd::ExportBlocksCmd, export_state_cmd::ExportStateCmd, generate::GenerateCmd, + export_blocks_cmd::ExportBlocksCmd, export_chain_spec_cmd::ExportChainSpecCmd, + export_state_cmd::ExportStateCmd, generate::GenerateCmd, generate_node_key::GenerateKeyCmdCommon, import_blocks_cmd::ImportBlocksCmd, insert_key::InsertKeyCmd, inspect_key::InspectKeyCmd, inspect_node_key::InspectNodeKeyCmd, key::KeySubcommand, purge_chain_cmd::PurgeChainCmd, revert_cmd::RevertCmd, run_cmd::RunCmd, - sign::SignCmd, vanity::VanityCmd, verify::VerifyCmd, export_chain_spec_cmd::ExportChainSpecCmd, + sign::SignCmd, vanity::VanityCmd, verify::VerifyCmd, }; -- GitLab