Skip to content

Commit 334f2e6

Browse files
Merge pull request #49 from wp-cli/issue_42
Use pretty name in list to cater for mixed-case names; add as optional field.
2 parents 1c6e76e + aae3f6f commit 334f2e6

2 files changed

Lines changed: 55 additions & 2 deletions

File tree

features/package-install.feature

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,54 @@ Feature: Install WP-CLI packages
194194
wp-cli/google-sitemap-generator-cli
195195
"""
196196

197+
@github-api
198+
Scenario: Install a package from a Git URL with mixed case git name but lower case composer.json name
199+
Given an empty directory
200+
201+
When I try `wp package install https://github.com/CapitalWPCLI/examplecommand.git`
202+
Then the return code should be 0
203+
And STDERR should contain:
204+
"""
205+
Warning: Package name mismatch...Updating the name with correct value.
206+
"""
207+
And STDOUT should contain:
208+
"""
209+
Success: Package installed.
210+
"""
211+
212+
When I run `wp package list --fields=name,pretty_name`
213+
Then STDOUT should be a table containing rows:
214+
| name | pretty_name |
215+
| capitalwpcli/examplecommand | capitalwpcli/examplecommand |
216+
217+
When I run `wp hello-world`
218+
Then STDOUT should contain:
219+
"""
220+
Success: Hello world.
221+
"""
222+
223+
@github-api
224+
Scenario: Install a package from a Git URL with mixed case git name and the same mixed case composer.json name
225+
Given an empty directory
226+
227+
When I run `wp package install https://github.com/gitlost/TestMixedCaseCommand.git`
228+
Then STDERR should be empty
229+
And STDOUT should contain:
230+
"""
231+
Success: Package installed.
232+
"""
233+
234+
When I run `wp package list --fields=name,pretty_name`
235+
Then STDOUT should be a table containing rows:
236+
| name | pretty_name |
237+
| gitlost/testmixedcasecommand | gitlost/TestMixedCaseCommand |
238+
239+
When I run `wp TestMixedCaseCommand`
240+
Then STDOUT should contain:
241+
"""
242+
Success: Test Mixed Case Command Name
243+
"""
244+
197245
# Current releases of schlessera/test-command are PHP 5.5 dependent.
198246
@github-api @shortened @require-php-5.5
199247
Scenario: Install a package from Git using a shortened package identifier

src/Package_Command.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ class Package_Command extends WP_CLI_Command {
114114
* * authors
115115
* * version
116116
*
117-
* There are no optionally available fields.
117+
* These fields are optionally available:
118+
*
119+
* * pretty_name
118120
*
119121
* ## EXAMPLES
120122
*
@@ -376,6 +378,7 @@ public function install( $args, $assoc_args ) {
376378
* These fields are optionally available:
377379
*
378380
* * description
381+
* * pretty_name
379382
*
380383
* ## EXAMPLES
381384
*
@@ -681,6 +684,7 @@ private function show_packages( $context, $packages, $assoc_args ) {
681684
}
682685
$package_output['update'] = $update;
683686
$package_output['update_version'] = $update_version;
687+
$package_output['pretty_name'] = $package->getPrettyName();
684688
$list[ $package_output['name'] ] = $package_output;
685689
}
686690
}
@@ -742,7 +746,8 @@ private function get_installed_packages() {
742746
}
743747
$installed_packages = array();
744748
foreach( $repo->getCanonicalPackages() as $package ) {
745-
if ( in_array( $package->getName(), $installed_package_keys, true ) ) {
749+
// Use pretty name as it's case sensitive.
750+
if ( in_array( $package->getPrettyName(), $installed_package_keys, true ) ) {
746751
$installed_packages[] = $package;
747752
}
748753
}

0 commit comments

Comments
 (0)