From a5a5807be9c11d7aa597c8bcc10146e6f8927b48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Droz?= Date: Fri, 27 Jul 2018 16:59:29 -0300 Subject: [PATCH] separate command argument handling from actual __invoke() --- src/MakePotCommand.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/MakePotCommand.php b/src/MakePotCommand.php index 840b2553..817db8ff 100644 --- a/src/MakePotCommand.php +++ b/src/MakePotCommand.php @@ -102,6 +102,18 @@ class MakePotCommand extends WP_CLI_Command { * @when before_wp_load */ public function __invoke( $args, $assoc_args ) { + $this->handle_arguments( $args, $assoc_args ); + if ( ! $this->makepot() ) { + WP_CLI::error( 'Could not generate a POT file!' ); + } + + WP_CLI::success( 'POT file successfully generated!' ); + } + + /** + * Process arguments from command-line in a reusable way. + */ + public function handle_arguments( $args, $assoc_args ) { $this->source = realpath( $args[0] ); $this->slug = Utils\get_flag_value( $assoc_args, 'slug', Utils\basename( $this->source ) ); $this->skip_js = Utils\get_flag_value( $assoc_args, 'skip-js', $this->skip_js ); @@ -162,12 +174,6 @@ public function __invoke( $args, $assoc_args ) { $this->exclude = array_map( [ $this, 'unslashit' ], $this->exclude); $this->exclude = array_unique( $this->exclude ); } - - if ( ! $this->makepot() ) { - WP_CLI::error( 'Could not generate a POT file!' ); - } - - WP_CLI::success( 'POT file successfully generated!' ); } /**