Skip to content

Commit

Permalink
Add Runtime::OmniNode variant to polkadot-parachain (paritytech#4805
Browse files Browse the repository at this point in the history
)

Adding `Runtime::OmniNode` variant + small changes

---------

Co-authored-by: kianenigma <[email protected]>
  • Loading branch information
2 people authored and TarekkMA committed Aug 2, 2024
1 parent 97062d0 commit fecf9af
Show file tree
Hide file tree
Showing 3 changed files with 253 additions and 171 deletions.
33 changes: 19 additions & 14 deletions cumulus/polkadot-parachain/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.

use clap::{CommandFactory, FromArgMatches};
use clap::{Command, CommandFactory, FromArgMatches};
use sc_cli::SubstrateCli;
use std::path::PathBuf;

/// Sub-commands supported by the collator.
Expand Down Expand Up @@ -58,22 +59,13 @@ pub enum Subcommand {
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
}

const AFTER_HELP_EXAMPLE: &str = color_print::cstr!(
r#"<bold><underline>Examples:</></>
<bold>polkadot-parachain --chain asset-hub-polkadot --sync warp -- --chain polkadot --sync warp</>
Launch a warp-syncing full node of the <italic>Asset Hub</> parachain on the <italic>Polkadot</> Relay Chain.
<bold>polkadot-parachain --chain asset-hub-polkadot --sync warp --relay-chain-rpc-url ws://rpc.example.com -- --chain polkadot</>
Launch a warp-syncing full node of the <italic>Asset Hub</> parachain on the <italic>Polkadot</> Relay Chain.
Uses <italic>ws://rpc.example.com</> as remote relay chain node.
"#
);
#[derive(Debug, clap::Parser)]
#[command(
propagate_version = true,
args_conflicts_with_subcommands = true,
subcommand_negates_reqs = true
subcommand_negates_reqs = true,
after_help = crate::examples(Self::executable_name())
)]
#[clap(after_help = AFTER_HELP_EXAMPLE)]
pub struct Cli {
#[command(subcommand)]
pub subcommand: Option<Subcommand>,
Expand All @@ -93,7 +85,7 @@ pub struct Cli {

/// Relay chain arguments
#[arg(raw = true)]
pub relaychain_args: Vec<String>,
pub relay_chain_args: Vec<String>,
}

#[derive(Debug)]
Expand All @@ -109,12 +101,25 @@ pub struct RelayChainCli {
}

impl RelayChainCli {
fn polkadot_cmd() -> Command {
let help_template = color_print::cformat!(
"The arguments that are passed to the relay chain node. \n\
\n\
<bold><underline>RELAY_CHAIN_ARGS:</></> \n\
{{options}}",
);

polkadot_cli::RunCmd::command()
.no_binary_name(true)
.help_template(help_template)
}

/// Parse the relay chain CLI parameters using the parachain `Configuration`.
pub fn new<'a>(
para_config: &sc_service::Configuration,
relay_chain_args: impl Iterator<Item = &'a String>,
) -> Self {
let polkadot_cmd = polkadot_cli::RunCmd::command().no_binary_name(true);
let polkadot_cmd = Self::polkadot_cmd();
let matches = polkadot_cmd.get_matches_from(relay_chain_args);
let base = FromArgMatches::from_arg_matches(&matches).unwrap_or_else(|e| e.exit());

Expand Down
Loading

0 comments on commit fecf9af

Please sign in to comment.