Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions features/language-plugin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,24 @@ Feature: Manage translation files for a WordPress install
"""
And STDOUT should be empty
And the return code should be 0

@require-wp-4.0
Scenario: Not providing plugin slugs should throw an error unless --all given
Given a WP install
And I run `wp plugin path`
And save STDOUT as {PLUGIN_DIR}

When I try `wp language plugin list`
Then the return code should be 1
And STDERR should be:
"""
Error: Please specify one or more plugins, or use --all.
"""
And STDOUT should be empty

Given an empty {PLUGIN_DIR} directory
When I run `wp language plugin list --all`
Then STDOUT should be:
"""
Success: No plugins installed.
"""
21 changes: 21 additions & 0 deletions features/language-theme.feature
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,24 @@ Feature: Manage translation files for a WordPress install
"""
And STDOUT should be empty
And the return code should be 0

@require-wp-4.0
Scenario: Not providing theme slugs should throw an error unless --all given
Given a WP install
And I run `wp theme path`
And save STDOUT as {THEME_DIR}

When I try `wp language theme list`
Then the return code should be 1
And STDERR should be:
"""
Error: Please specify one or more themes, or use --all.
"""
And STDOUT should be empty

Given an empty {THEME_DIR} directory
When I run `wp language theme list --all`
Then STDOUT should be:
"""
Success: No themes installed.
"""
11 changes: 10 additions & 1 deletion src/Plugin_Language_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Plugin_Language_Command extends WP_CLI\CommandWithTranslation {
);

/**
* Lists all available languages.
* Lists all available languages for one or more plugins.
*
* ## OPTIONS
*
Expand Down Expand Up @@ -97,10 +97,19 @@ class Plugin_Language_Command extends WP_CLI\CommandWithTranslation {
public function list_( $args, $assoc_args ) {
$all = \WP_CLI\Utils\get_flag_value( $assoc_args, 'all', false );

if ( ! $all && empty( $args ) ) {
WP_CLI::error( 'Please specify one or more plugins, or use --all.' );
}

if ( $all ) {
$args = array_map( function( $file ){
return \WP_CLI\Utils\get_plugin_name( $file );
}, array_keys( $this->get_all_plugins() ) );

if ( empty( $args ) ) {
WP_CLI::success( 'No plugins installed.' );
return;
}
}

$updates = $this->get_translation_updates();
Expand Down
11 changes: 10 additions & 1 deletion src/Theme_Language_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Theme_Language_Command extends WP_CLI\CommandWithTranslation {
);

/**
* Lists all available languages.
* Lists all available languages for one or more themes.
*
* ## OPTIONS
*
Expand Down Expand Up @@ -97,10 +97,19 @@ class Theme_Language_Command extends WP_CLI\CommandWithTranslation {
public function list_( $args, $assoc_args ) {
$all = \WP_CLI\Utils\get_flag_value( $assoc_args, 'all', false );

if ( ! $all && empty( $args ) ) {
WP_CLI::error( 'Please specify one or more themes, or use --all.' );
}

if ( $all ) {
$args = array_map( function( $file ){
return \WP_CLI\Utils\get_theme_name( $file );
}, array_keys( wp_get_themes() ) );

if ( empty( $args ) ) {
WP_CLI::success( 'No themes installed.' );
return;
}
}

$updates = $this->get_translation_updates();
Expand Down