mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 23:05:42 +00:00
Adder Parachain: Accept output file argument to export-genesis-* subcommands (#2370)
This PR makes a small change the the adder parachain's CLI. It allows the user to specify an output file explicitly when generating the genesis wasm and head data. Now we no longer have to rely on redirecting the output to a file at the shell level. This change is nice because if you have any debugging lines enabled, shell redirection does not work. More to the point, this makes the adder parachain's CLI match the cumulus collator's CLI. And that will allow tools like Zombienet (that support both cumulus and the adder) to use the positional argument. cc @pepoviola --------- Co-authored-by: Joshy Orndorff <git-user-email.h0ly5@simplelogin.com> Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -22,6 +22,10 @@ use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProt
|
||||
use polkadot_primitives::Id as ParaId;
|
||||
use sc_cli::{Error as SubstrateCliError, SubstrateCli};
|
||||
use sp_core::hexdisplay::HexDisplay;
|
||||
use std::{
|
||||
fs,
|
||||
io::{self, Write},
|
||||
};
|
||||
use test_parachain_adder_collator::Collator;
|
||||
|
||||
/// The parachain ID to collate for in case it wasn't set explicitly through CLI.
|
||||
@@ -34,15 +38,29 @@ fn main() -> Result<()> {
|
||||
let cli = Cli::from_args();
|
||||
|
||||
match cli.subcommand {
|
||||
Some(cli::Subcommand::ExportGenesisState(_params)) => {
|
||||
Some(cli::Subcommand::ExportGenesisState(params)) => {
|
||||
let collator = Collator::new();
|
||||
println!("0x{:?}", HexDisplay::from(&collator.genesis_head()));
|
||||
let output_buf =
|
||||
format!("0x{:?}", HexDisplay::from(&collator.genesis_head())).into_bytes();
|
||||
|
||||
if let Some(output) = params.output {
|
||||
std::fs::write(output, output_buf)?;
|
||||
} else {
|
||||
std::io::stdout().write_all(&output_buf)?;
|
||||
}
|
||||
|
||||
Ok::<_, Error>(())
|
||||
},
|
||||
Some(cli::Subcommand::ExportGenesisWasm(_params)) => {
|
||||
Some(cli::Subcommand::ExportGenesisWasm(params)) => {
|
||||
let collator = Collator::new();
|
||||
println!("0x{:?}", HexDisplay::from(&collator.validation_code()));
|
||||
let output_buf =
|
||||
format!("0x{:?}", HexDisplay::from(&collator.validation_code())).into_bytes();
|
||||
|
||||
if let Some(output) = params.output {
|
||||
fs::write(output, output_buf)?;
|
||||
} else {
|
||||
io::stdout().write_all(&output_buf)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user