Skip to content

Commit

Permalink
WIP implement Subcommand manually (see paritytech/substrate#6894 (com…
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdplm committed Sep 23, 2020
1 parent 9f81da1 commit 6a0fbf2
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 16 deletions.
28 changes: 27 additions & 1 deletion test-node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,36 @@

use sc_cli::{
RunCmd,
Subcommand,
BuildSpecCmd,
// ExportBlocksCmd, ImportBlocksCmd, CheckBlockCmd, ExportStateCmd, RevertCmd,
PurgeChainCmd,
// Subcommand,
CliConfiguration, SharedParams,
};
use structopt::StructOpt;

#[derive(Debug, StructOpt)]
pub enum Subcommand {
/// Build a spec.json file, outputs to stdout.
BuildSpec(BuildSpecCmd),
/// Export blocks to a file.
// ExportBlocks(ExportBlocksCmd),
/// Import blocks from file.
// ImportBlocks(ImportBlocksCmd),
/// Validate a single block.
// CheckBlock(CheckBlockCmd),
/// Export state as raw chain spec.
// ExportState(ExportStateCmd),
/// Revert chain to the previous state.
// Revert(RevertCmd),
/// Remove the whole chain data.
PurgeChain(PurgeChainCmd),
}

impl CliConfiguration for Subcommand {
fn shared_params(&self) -> &SharedParams { todo!() }
}

#[derive(Debug, StructOpt)]
pub struct Cli {
#[structopt(subcommand)]
Expand Down
32 changes: 17 additions & 15 deletions test-node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use crate::{
chain_spec,
cli::Cli,
cli::{Cli, Subcommand},
service,
};
use sc_cli::{
Expand All @@ -25,7 +25,7 @@ use sc_cli::{
RuntimeVersion,
SubstrateCli,
};
use sc_service::PartialComponents;
// use sc_service::PartialComponents;

impl SubstrateCli for Cli {
fn impl_name() -> String {
Expand Down Expand Up @@ -74,19 +74,21 @@ pub fn run() -> sc_cli::Result<()> {
let cli = Cli::from_args();

match &cli.subcommand {
Some(subcommand) => {
let runner = cli.create_runner(subcommand)?;
runner.run_subcommand(subcommand, |config| {
let PartialComponents {
client,
backend,
task_manager,
import_queue,
..
} = service::new_partial(&config)?;
Ok((client, backend, import_queue, task_manager))
})
}
Some(Subcommand::BuildSpec(_cmd)) => todo!(),
Some(Subcommand::PurgeChain(_cmd)) => todo!(),
// Some(subcommand) => {
// let runner = cli.create_runner(subcommand)?;
// runner.run_subcommand(subcommand, |config| {
// let PartialComponents {
// client,
// backend,
// task_manager,
// import_queue,
// ..
// } = service::new_partial(&config)?;
// Ok((client, backend, import_queue, task_manager))
// })
// }
None => {
let runner = cli.create_runner(&cli.run)?;
runner.run_node_until_exit(|config| {
Expand Down

0 comments on commit 6a0fbf2

Please sign in to comment.