Skip to main content

terraform_wrapper/
command.rs

1use crate::Terraform;
2use crate::error::Result;
3
4/// Trait implemented by all Terraform command builders.
5///
6/// Each command implements [`args`](TerraformCommand::args) to produce its CLI
7/// arguments and [`execute`](TerraformCommand::execute) to run against a
8/// [`Terraform`] client.
9pub trait TerraformCommand: Send + Sync {
10    /// The output type produced by this command.
11    type Output: Send;
12
13    /// Build the argument list for this command.
14    ///
15    /// Returns the subcommand name followed by all flags and options.
16    /// For example: `["init", "-upgrade", "-backend-config=key=value"]`.
17    fn args(&self) -> Vec<String>;
18
19    /// Execute this command against the given Terraform client.
20    fn execute(
21        &self,
22        tf: &Terraform,
23    ) -> impl std::future::Future<Output = Result<Self::Output>> + Send;
24}