Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/pop-cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl Command {
None => up::Command::execute(args).await.map(Up),
Some(cmd) => match cmd {
#[cfg(feature = "parachain")]
up::Command::Network(cmd) => cmd.execute().await.map(|_| Up(crate::common::Project::Network)),
up::Command::Network(cmd) => cmd.execute(&mut Cli).await.map(|_| Up(crate::common::Project::Network)),
},
}
},
Expand Down
40 changes: 36 additions & 4 deletions crates/pop-cli/src/commands/up/network.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// SPDX-License-Identifier: GPL-3.0

use crate::style::{style, Theme};
use crate::{
cli::traits::{Cli, MultiSelect},
style::{style, Theme},
};
use clap::Args;
use cliclack::{
clear_screen, confirm, intro, log, multi_progress, outro, outro_cancel, set_theme, spinner,
Expand All @@ -9,8 +12,8 @@ use cliclack::{
use console::{Emoji, Style, Term};
use duct::cmd;
use pop_common::Status;
use pop_parachains::{clear_dmpq, Error, IndexSet, NetworkNode, RelayChain, Zombienet};
use std::{path::Path, time::Duration};
use pop_parachains::{clear_dmpq, Binary, Error, IndexSet, NetworkNode, RelayChain, Zombienet};
use std::{collections::HashSet, path::Path, time::Duration};
use tokio::time::sleep;

#[derive(Args, Clone)]
Expand Down Expand Up @@ -53,7 +56,7 @@ pub(crate) struct ZombienetCommand {

impl ZombienetCommand {
/// Executes the command.
pub(crate) async fn execute(self) -> anyhow::Result<()> {
pub(crate) async fn execute(self, cli: &mut crate::cli::Cli) -> anyhow::Result<()> {
clear_screen()?;
intro(format!("{}: Launch a local network", style(" Pop CLI ").black().on_magenta()))?;
set_theme(Theme);
Expand Down Expand Up @@ -86,6 +89,8 @@ impl ZombienetCommand {
},
};

Self::build_local_binaries(&mut zombienet, cli).await;

// Source any missing/stale binaries
if Self::source_binaries(&mut zombienet, &cache, self.verbose, self.skip_confirm).await? {
return Ok(());
Expand Down Expand Up @@ -189,6 +194,33 @@ impl ZombienetCommand {
Ok(())
}

async fn build_local_binaries(
zombienet: &mut Zombienet,
cli: &mut crate::cli::Cli,
) -> anyhow::Result<()> {
let mut prompt =
cli.multiselect(r#"Select local runtime binaries to rebuild"#).required(false);
let binaries: Vec<Binary> = zombienet.binaries().map(|b| b.clone()).collect();
for binary in binaries.iter() {
if binary.local() && ["./", "../", "/"].iter().any(|p| binary.path().starts_with(p)) {
let binary_name = binary.name();
prompt = prompt.item(
binary_name.to_string(),
binary_name,
binary.path().to_str().unwrap(),
);
}
}
let binary_names = prompt.interact()?;
for binary in binaries {
if binary_names.contains(&binary.name().to_string()) {
// Build the binary.
}
}

Ok(())
}

async fn source_binaries(
zombienet: &mut Zombienet,
cache: &Path,
Expand Down
2 changes: 1 addition & 1 deletion crates/pop-common/src/sourcing/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
use std::path::{Path, PathBuf};

/// A binary used to launch a node.
#[derive(Debug, PartialEq)]
#[derive(Debug, Clone, PartialEq)]
pub enum Binary {
/// A local binary.
Local {
Expand Down