-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add the "pop up contracts-node" command (#185)
* Add the "pop up contracts-node" command * Adapt wording * Restore README paragraph
- Loading branch information
Showing
5 changed files
with
51 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
use clap::Args; | ||
use cliclack::{clear_screen, intro, set_theme}; | ||
use duct::cmd; | ||
|
||
use crate::style::{style, Theme}; | ||
|
||
const BIN_NAME: &str = "substrate-contracts-node"; | ||
|
||
#[derive(Args)] | ||
pub(crate) struct ContractsNodeCommand; | ||
impl ContractsNodeCommand { | ||
pub(crate) async fn execute(&self) -> anyhow::Result<()> { | ||
clear_screen()?; | ||
intro(format!("{}: Launch a contracts node", style(" Pop CLI ").black().on_magenta()))?; | ||
set_theme(Theme); | ||
|
||
let cache = crate::cache()?; | ||
let cached_file = cache.join("bin").join(BIN_NAME); | ||
if !cached_file.exists() { | ||
cmd( | ||
"cargo", | ||
vec!["install", "--root", cache.display().to_string().as_str(), "contracts-node"], | ||
) | ||
.run()?; | ||
} | ||
cmd(cached_file.display().to_string().as_str(), Vec::<&str>::new()).run()?; | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters