use std::process::ExitCode;
use clap::{Args, Subcommand};
use crate::config::ResolvedContext;
use crate::output::OutputFormat;
pub mod get;
pub mod history;
pub mod list;
pub mod show;
pub mod simulate;
pub mod validate;
#[derive(Args)]
pub struct PolicyArgs {
#[command(subcommand)]
pub command: PolicyCommands,
}
#[derive(Subcommand)]
pub enum PolicyCommands {
Apply(history::ApplyArgs),
History(history::HistoryArgs),
Rollback(history::RollbackArgs),
Diff(history::DiffArgs),
Simulate(simulate::SimulateArgs),
Validate(validate::ValidateArgs),
Get(get::GetArgs),
List(list::ListArgs),
Show(show::ShowArgs),
}
pub fn dispatch(args: PolicyArgs, ctx: &ResolvedContext, output: OutputFormat) -> ExitCode {
match args.command {
PolicyCommands::Apply(apply_args) => history::run_apply(apply_args, ctx),
PolicyCommands::History(history_args) => history::run_history(history_args),
PolicyCommands::Rollback(rollback_args) => history::run_rollback(rollback_args),
PolicyCommands::Diff(diff_args) => history::run_diff(diff_args),
PolicyCommands::Simulate(sim_args) => simulate::run(sim_args),
PolicyCommands::Validate(val_args) => validate::run(val_args),
PolicyCommands::Get(get_args) => get::run(get_args),
PolicyCommands::List(list_args) => list::run(list_args, ctx, output),
PolicyCommands::Show(show_args) => show::run(show_args, ctx, output),
}
}