35 lines
1.0 KiB
Rust
35 lines
1.0 KiB
Rust
use anyhow::Context;
|
|
use clap::{ArgMatches, Command};
|
|
|
|
use crate::cli::CuddleCli;
|
|
|
|
use super::{folder::FolderCommand, kustomize::KustomizeCommand};
|
|
|
|
pub fn build_command(root_cmd: Command) -> Command {
|
|
let cmd = Command::new("render").about("accesses different render commands");
|
|
|
|
let cmd = super::kustomize::build_command(cmd);
|
|
let cmd = super::folder::build_command(cmd);
|
|
|
|
root_cmd.subcommand(cmd)
|
|
}
|
|
|
|
pub struct RenderCommand {}
|
|
impl RenderCommand {
|
|
pub fn execute(matches: &ArgMatches, cli: CuddleCli) -> anyhow::Result<()> {
|
|
match matches.subcommand() {
|
|
Some(("kustomize", sub_matches)) => {
|
|
KustomizeCommand::from_matches(sub_matches, cli)?.execute()?;
|
|
}
|
|
Some(("folder", sub_matches)) => {
|
|
FolderCommand::from_matches(sub_matches, cli)?
|
|
.execute()
|
|
.context("failed to render folder")?;
|
|
}
|
|
_ => anyhow::bail!("failed to find match for render"),
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
}
|