instance command done

This commit is contained in:
Sayantan Karmakar 2022-03-31 23:27:33 +05:30
parent 9980b13142
commit 66e16aa1db
5 changed files with 33 additions and 3 deletions

View File

@ -9,12 +9,12 @@ use anyhow::Result;
use crate::{
config::{with_config, ConfigOverride},
errors::DevToolError,
utils::is_initilized,
utils::is_initialized,
};
pub fn deploy(cfg_override: &ConfigOverride, cluster: Option<Cluster>) -> Result<()> {
with_config(cfg_override, |cfg| {
if !is_initilized() {
if !is_initialized() {
return Err(DevToolError::NotInitialized.into());
}

View File

@ -0,0 +1,26 @@
use anyhow::Result;
use std::process::{Command, Stdio};
use crate::{errors::DevToolError, utils::is_initialized};
pub fn instance() -> Result<()> {
if !is_initialized() {
return Err(DevToolError::NotInitialized.into());
}
let address = Command::new("solana")
.arg("address")
.arg("-k")
.arg("./dev-tools/serum-dex-dev.json")
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.output()
.expect("Must get address");
if !address.status.success() {
println!("There was a problem running solana address: {:?}.", address);
std::process::exit(address.status.code().unwrap_or(1));
}
Ok(())
}

View File

@ -1,5 +1,7 @@
mod deploy;
mod init;
mod instance;
pub use deploy::*;
pub use init::*;
pub use instance::*;

View File

@ -21,12 +21,14 @@ pub struct Opts {
#[derive(Debug, Parser)]
pub enum Command {
Init,
Instance,
Deploy { cluster: Option<Cluster> },
}
pub fn entry(opts: Opts) -> Result<()> {
match opts.command {
Command::Init => commands::init(),
Command::Instance => commands::instance(),
Command::Deploy { cluster } => commands::deploy(&opts.cfg_override, cluster),
}
}

View File

@ -1,6 +1,6 @@
use std::path::Path;
pub fn is_initilized() -> bool {
pub fn is_initialized() -> bool {
// Check if initialized
if !Path::exists(Path::new("./dev-tools")) {
return false;