Skip to content

Commit

Permalink
Add --config option
Browse files Browse the repository at this point in the history
  • Loading branch information
riseshia committed Jun 22, 2024
1 parent daa17a0 commit e33bd94
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/commands/apply.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pub struct ApplyCommand;

use std::process::exit;

use super::plan::PlanCommand;

pub struct ApplyCommand;

impl ApplyCommand {
pub fn run(force: &bool) {
pub fn run(force: &bool, config: &str) {
if !force {
PlanCommand::run();
PlanCommand::run(config);

print!(
r#"
Expand All @@ -20,11 +20,11 @@ Enter a value: "#
let response: String = read!("{}\n");

if response != "yes" {
println!("apply canceled!");
println!("apply cancelled!");
exit(1)
}
}

println!("apply called!")
println!("apply called with {}!", config);
}
}
4 changes: 2 additions & 2 deletions src/commands/plan.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
pub struct PlanCommand;

impl PlanCommand {
pub fn run() {
pub fn run(config: &str) {
// read config
// fetch resource from aws api
// diff
// emit changed resource based on diff
println!("plan called!")
println!("plan called with {}!", config)
}
}
17 changes: 12 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ enum Commands {
/// Skip to check changes, but only apply it.
#[arg(short, long)]
force: bool,
/// Config file
#[arg(short, long, default_value = "fubura.jsonnet")]
config: String,
},
/// plan config
Plan,
Plan {
/// Config file
#[arg(short, long, default_value = "fubura.jsonnet")]
config: String,
},
}

use fubura::commands::apply::ApplyCommand;
Expand All @@ -26,11 +33,11 @@ use fubura::commands::plan::PlanCommand;
fn main() {
let cli = Cli::parse();
match &cli.command {
Commands::Apply { force } => {
ApplyCommand::run(force);
Commands::Apply { force, config } => {
ApplyCommand::run(force, config);
}
Commands::Plan => {
PlanCommand::run();
Commands::Plan { config } => {
PlanCommand::run(config);
}
}
}

0 comments on commit e33bd94

Please sign in to comment.