use super::force;
use crate::cli::invocation::flags;
use crate::cli::{CliCommand, Invocation};
use crate::command::{Cascade, DryRun, Rollback, ServerSide, Test, Uninstall, WaitStrategy};
use crate::error::Result;
impl CliCommand for Rollback {
const MUTATES: bool = true;
fn build(&self, inv: &mut Invocation) -> Result<()> {
inv.arg("rollback");
inv.arg(&self.release);
if let Some(revision) = self.revision {
inv.arg(revision.to_string());
}
flags! { inv, self;
switch("--cleanup-on-fail", cleanup_on_fail);
option("--description", description);
}
inv.equals("--dry-run", self.dry_run.map(DryRun::as_str));
force(inv, self.force);
flags! { inv, self;
number("--history-max", history_max);
switch("--no-hooks", no_hooks);
}
inv.equals("--server-side", self.server_side.map(ServerSide::as_str));
inv.timeout(self.timeout);
inv.equals("--wait", self.wait.map(WaitStrategy::as_str));
flags! { inv, self;
switch("--wait-for-jobs", wait_for_jobs);
}
Ok(())
}
fn parse(&self, _stdout: String) -> Result<()> {
Ok(())
}
}
impl CliCommand for Uninstall {
const MUTATES: bool = true;
fn build(&self, inv: &mut Invocation) -> Result<()> {
inv.arg("uninstall");
for release in &self.releases {
inv.arg(release);
}
inv.equals("--cascade", self.cascade.map(Cascade::as_str));
flags! { inv, self;
option("--description", description);
switch("--dry-run", dry_run);
switch("--ignore-not-found", ignore_not_found);
switch("--keep-history", keep_history);
switch("--no-hooks", no_hooks);
}
inv.timeout(self.timeout);
inv.equals("--wait", self.wait.map(WaitStrategy::as_str));
Ok(())
}
fn parse(&self, _stdout: String) -> Result<()> {
Ok(())
}
}
impl CliCommand for Test {
const MUTATES: bool = true;
fn build(&self, inv: &mut Invocation) -> Result<()> {
inv.arg("test");
inv.arg(&self.release);
flags! { inv, self;
each("--filter", filter);
switch("--logs", logs);
}
inv.timeout(self.timeout);
Ok(())
}
fn parse(&self, stdout: String) -> Result<String> {
Ok(stdout)
}
}