Skip to content

Commit

Permalink
add: flag in run command to supply additional madara flags
Browse files Browse the repository at this point in the history
  • Loading branch information
anshalshukla committed Feb 17, 2024
1 parent bb9a4ba commit ac46e53
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ pub enum RunError {
Other(#[from] eyre::Error),
}

pub async fn run(chain_name: &Option<String>) {
match start_app_chain(chain_name).await {
pub async fn run(chain_name: &Option<String>, madara_flags: &Option<String>) {
match start_app_chain(chain_name, madara_flags).await {
Ok(_) => {
log::info!("Madara setup successful");
}
Expand All @@ -35,7 +35,7 @@ pub async fn run(chain_name: &Option<String>) {
}
}

async fn start_app_chain(chain_name: &Option<String>) -> Result<(), RunError> {
async fn start_app_chain(chain_name: &Option<String>, madara_flags: &Option<String>) -> Result<(), RunError> {
let app_chain: String = match chain_name {
Some(chain_name) => chain_name.to_string(),
None => {
Expand All @@ -58,7 +58,7 @@ async fn start_app_chain(chain_name: &Option<String>) -> Result<(), RunError> {
da_factory.confirm_minimum_balance(&config)?;
da_factory.setup(&config).await?;

madara::setup_and_run_madara(config)?;
madara::setup_and_run_madara(config, madara_flags.as_ref().unwrap_or(&String::from("")))?;

Ok(())
}
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ enum Commands {
/// App chain name
#[arg(short, long = "chain-name")]
name: Option<String>,
/// Additional arguments for Madara
#[arg(short, long = "madara-flags")]
flags: Option<String>,
},
/// Runs the L2 explorer
Explorer(ExplorerOpts),
Expand All @@ -50,7 +53,7 @@ async fn main() {
match &cli.command {
Some(Commands::Init { name, mode, da }) => cli::init::init(name, mode, da).await,
Some(Commands::List) => cli::list::list(),
Some(Commands::Run { name }) => cli::run::run(name).await,
Some(Commands::Run { name, flags }) => cli::run::run(name, flags).await,
Some(Commands::Explorer(opts)) => cli::explorer::explorer(opts).await,
None => log::info!("Use --help to see the complete list of available commands"),
}
Expand Down
9 changes: 8 additions & 1 deletion src/utils/madara.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn clone_madara_and_build_repo(config: &AppChainConfig) -> Result<(), Madara
Ok(())
}

pub fn setup_and_run_madara(config: AppChainConfig) -> Result<(), MadaraError> {
pub fn setup_and_run_madara(config: AppChainConfig, flags: &String) -> Result<(), MadaraError> {
let madara_path = get_madara_home()?.join("madara");

let app_home = get_app_home(config.app_chain.as_str())?;
Expand All @@ -60,6 +60,13 @@ pub fn setup_and_run_madara(config: AppChainConfig) -> Result<(), MadaraError> {
&base_path,
];

args.extend(
flags
.split(",")
.map(|flag| flag.trim())
.filter(|flag| !flag.is_empty())
);

match config.da_layer {
DALayer::Ethereum => {
let ethereum_conf = vec!["--da-layer=ethereum", &da_conf];
Expand Down

0 comments on commit ac46e53

Please sign in to comment.