mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 08:37:56 +00:00
Handle piping error for commands that output to stdout (#6098)
* Handle piping error for commands that output to stdout * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -22,7 +22,7 @@ use crate::{
|
||||
use log::info;
|
||||
use sc_service::{Configuration, ServiceBuilderCommand};
|
||||
use sp_runtime::traits::{Block as BlockT, NumberFor};
|
||||
use std::{fmt::Debug, str::FromStr};
|
||||
use std::{fmt::Debug, str::FromStr, io::Write};
|
||||
use structopt::StructOpt;
|
||||
|
||||
/// The `export-state` command used to export the state of a given block into
|
||||
@@ -65,9 +65,9 @@ impl ExportStateCmd {
|
||||
|
||||
info!("Generating new chain spec...");
|
||||
let json = sc_service::chain_ops::build_spec(&*input_spec, true)?;
|
||||
|
||||
print!("{}", json);
|
||||
|
||||
if std::io::stdout().write_all(json.as_bytes()).is_err() {
|
||||
let _ = std::io::stderr().write_all(b"Error writing to stdout\n");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user