add script option to deploy command
This commit is contained in:
parent
1a3b5757ab
commit
9f83e6cbdd
|
@ -12,7 +12,11 @@ use crate::{
|
|||
utils::is_initialized,
|
||||
};
|
||||
|
||||
pub fn deploy(cfg_override: &ConfigOverride, cluster: Option<Cluster>) -> Result<()> {
|
||||
pub fn deploy(
|
||||
cfg_override: &ConfigOverride,
|
||||
cluster: Option<Cluster>,
|
||||
script: Option<String>,
|
||||
) -> Result<()> {
|
||||
with_config(cfg_override, |cfg| {
|
||||
if !is_initialized() {
|
||||
return Err(DevToolError::NotInitialized.into());
|
||||
|
@ -48,6 +52,20 @@ pub fn deploy(cfg_override: &ConfigOverride, cluster: Option<Cluster>) -> Result
|
|||
|
||||
println!("Deploy Successful");
|
||||
|
||||
if script.is_some() {
|
||||
let script_exit = std::process::Command::new("bash")
|
||||
.arg("-c")
|
||||
.arg(script.unwrap())
|
||||
.stdout(Stdio::inherit())
|
||||
.stderr(Stdio::inherit())
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
if !script_exit.status.success() {
|
||||
std::process::exit(exit.status.code().unwrap_or(1));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
|
|
@ -22,13 +22,20 @@ pub struct Opts {
|
|||
pub enum Command {
|
||||
Init,
|
||||
Instance,
|
||||
Deploy { cluster: Option<Cluster> },
|
||||
Deploy {
|
||||
cluster: Option<Cluster>,
|
||||
|
||||
#[clap(long)]
|
||||
script: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
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),
|
||||
Command::Deploy { cluster, script } => {
|
||||
commands::deploy(&opts.cfg_override, cluster, script)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue