Skip to content

Commit

Permalink
Merge pull request #60 from drzraf/split-invoke-args
Browse files Browse the repository at this point in the history
Separate command argument handling from actual `__invoke()`
  • Loading branch information
schlessera authored Jul 31, 2018
2 parents 1a15b15 + 28f48d7 commit e1aa166
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/MakePotCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,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 ) {
$array_arguments = array( 'headers' );
$assoc_args = \WP_CLI\Utils\parse_shell_arrays( $assoc_args, $array_arguments );
$this->source = realpath( $args[0] );
Expand Down Expand Up @@ -173,12 +185,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!' );
}

/**
Expand Down

0 comments on commit e1aa166

Please sign in to comment.