diff --git a/crates/cli/src/commands/apply_migration.rs b/crates/cli/src/commands/apply_migration.rs index 056acae8b..73f19c56f 100644 --- a/crates/cli/src/commands/apply_migration.rs +++ b/crates/cli/src/commands/apply_migration.rs @@ -22,7 +22,7 @@ pub struct ApplyMigrationArgs { help_heading = "Workflow options", help = "JSON input parameter to pass to the workflow" )] - input: Option, + pub(crate) input: Option, #[clap( long, help_heading = "Workflow options", @@ -31,7 +31,7 @@ pub struct ApplyMigrationArgs { pub(crate) remote: bool, /// Print verbose output #[clap(long)] - verbose: bool, + pub(crate) verbose: bool, } impl ApplyMigrationArgs { diff --git a/crates/cli/src/commands/plumbing.rs b/crates/cli/src/commands/plumbing.rs index 431ef4203..9aaace3ba 100644 --- a/crates/cli/src/commands/plumbing.rs +++ b/crates/cli/src/commands/plumbing.rs @@ -10,6 +10,7 @@ use marzano_gritmodule::searcher::find_grit_modules_dir; use marzano_gritmodule::utils::is_pattern_name; use marzano_messenger::emit::ApplyDetails; use serde::{Deserialize, Serialize}; +use std::env::current_dir; use std::io::{stdin, Read}; use std::path::Path; use std::path::PathBuf; @@ -92,6 +93,14 @@ pub enum PlumbingArgs { #[command(flatten)] shared_args: SharedPlumbingArgs, }, + /// Run a workflow + #[cfg(feature = "workflows_v2")] + Run { + #[command(flatten)] + shared_args: SharedPlumbingArgs, + /// Workflow definition file + definition: String, + }, } fn read_input(shared_args: &SharedPlumbingArgs) -> Result { @@ -281,5 +290,34 @@ pub(crate) async fn run_plumbing( super::patterns_test::AggregatedTestResult::AllPassed => Ok(()), } } + #[cfg(feature = "workflows_v2")] + PlumbingArgs::Run { + shared_args, + definition, + } => { + let buffer = read_input(&shared_args)?; + + let current_dir = current_dir()?; + + let custom_workflow = marzano_gritmodule::searcher::find_workflow_file_from( + current_dir.clone(), + &definition, + ) + .await + .unwrap(); + + super::apply_migration::run_apply_migration( + custom_workflow, + vec![current_dir], + None, + super::apply_migration::ApplyMigrationArgs { + input: Some(buffer), + remote: false, + verbose: true, + }, + &parent, + ) + .await + } } }