@@ -19,11 +19,13 @@ class Workflow extends Command {
1919 */
2020 protected function configure () {
2121 $ this ->setName ( 'workflow ' )
22- ->setAliases ( [ 'do ' ] )
23- ->addArgument ( 'workflow ' , InputArgument::REQUIRED , 'The workflow you would like to run. ' )
24- ->addOption ( 'root ' , null , InputOption::VALUE_REQUIRED , 'Set the root directory for running commands. ' )
25- ->setDescription ( 'Run a command workflow. ' )
26- ->setHelp ( 'Run a command workflow. ' );
22+ ->setAliases ( [ 'do ' ] )
23+ ->addArgument ( 'workflow ' , InputArgument::REQUIRED , 'The workflow you would like to run. ' )
24+ ->addArgument ( 'extra_args ' , InputArgument::IS_ARRAY , 'Additional arguments to pass to the workflow. ' )
25+ ->addOption ( 'root ' , null , InputOption::VALUE_REQUIRED , 'Set the root directory for running commands. ' )
26+ ->addOption ( 'extra_options ' , null , InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL , 'Additional options to pass to the workflow. ' )
27+ ->setDescription ( 'Run a command workflow. ' )
28+ ->setHelp ( 'Run a command workflow. ' );
2729 }
2830
2931 /**
@@ -34,6 +36,8 @@ protected function execute( InputInterface $input, OutputInterface $output ) {
3436 $ config = App::getConfig ();
3537 $ root = $ input ->getOption ( 'root ' );
3638 $ workflow_slug = $ input ->getArgument ( 'workflow ' );
39+ $ extra_args = $ input ->getArgument ( 'extra_args ' );
40+ $ extra_options = $ input ->getOption ( 'extra_options ' );
3741 $ io = $ this ->getIO ();
3842 $ application = $ this ->getApplication ();
3943 if ( ! $ application ) {
@@ -73,8 +77,16 @@ protected function execute( InputInterface $input, OutputInterface $output ) {
7377 $ bail_on_failure = false ;
7478 $ step = substr ( $ step , 1 );
7579 }
76- $ io ->section ( "> <fg=cyan> {$ step }</> " );
77- system ( Env::set ( $ step ), $ result );
80+
81+ // Add extra arguments and options to the command.
82+ $ extra_args_string = implode ( ' ' , array_map ( 'escapeshellarg ' , $ extra_args ) );
83+ $ extra_options_string = implode ( ' ' , array_map ( static function ( $ option ) {
84+ return escapeshellarg ( $ option );
85+ }, $ extra_options ) );
86+ $ full_command = trim ( "{$ step } {$ extra_args_string } {$ extra_options_string }" );
87+
88+ $ io ->section ( "> <fg=cyan> {$ full_command }</> " );
89+ system ( Env::set ( $ full_command ), $ result );
7890 $ io ->newLine ();
7991
8092 if ( $ result ) {
0 commit comments