Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equalize theme folder naming conventions across Win/Mac/Linux #196

Merged
merged 10 commits into from Nov 8, 2019

Conversation

@beaucollins
Copy link
Contributor

beaucollins commented Sep 13, 2019

  • Test added and commits rebased on behalf of @achyuthajoy (PR #151)
  • Fixes #121
  • Error message when a case insensitive match exists has been improved:
wp theme delete P2
Error: The 'P2' theme could not be found. Did you mean 'p2'?

Modified Theme Fetcher to strict compare specified theme slug against existing ones as a Workaround to Operating System folder naming conventions.

This will equalize the non-lowercase slugs across all operating systems. If exact slug is not found, error is returned.

Fix to #121 - More info added to the bug report

-- @achyuthajoy

achyuthajoy and others added 3 commits Mar 3, 2019
… for WPCLI Themes
…d error
@beaucollins beaucollins requested a review from wp-cli/committers as a code owner Sep 13, 2019
@beaucollins beaucollins changed the title Fix 121 WP-CLI Themes: Added workaround to equalize folder naming conventions across Win/Mac/Linux Sep 13, 2019
@beaucollins beaucollins force-pushed the beaucollins:fix-121 branch from e8dedaa to 4b77088 Sep 13, 2019
@beaucollins beaucollins force-pushed the beaucollins:fix-121 branch from b373511 to 3663838 Sep 13, 2019
beaucollins added 2 commits Sep 14, 2019
…ress
* a case sensitive name.
* @return string|boolean Case sensitive name if match found, otherwise false.
*/
private function find_inexact_match( $name, $existing_themes ) {

This comment has been minimized.

Copy link
@schlessera

schlessera Sep 27, 2019

Member

We can integrate the suggestion algorithm in here that also accounts for typos.
First we need to add an import at the top of the file:

use WP_CLI\Utils;

Then we can use that to also recognise words that are "close enough":

private function find_inexact_match( $name, $existing_themes ) {
	$suggestion = Utils\find_suggestion(
		strtolower( $name ),
		array_keys( array_map( 'strtolower', $existing_themes ) )
	);

	if ( '' !== $suggestion ) {
		return $suggestion;
	}
	
	return false;
}

Now, you'll also receive suggestions with typos like:

Error: The 'Twentyelven' theme could not be found. Did you mean 'twentyeleven'?
src/WP_CLI/Fetchers/Theme.php Outdated Show resolved Hide resolved
src/WP_CLI/Fetchers/Theme.php Outdated Show resolved Hide resolved
beaucollins and others added 3 commits Sep 27, 2019
Co-Authored-By: Alain Schlesser <alain.schlesser@gmail.com>
Co-Authored-By: Alain Schlesser <alain.schlesser@gmail.com>
@schlessera schlessera added this to the 2.0.7 milestone Nov 8, 2019
@schlessera

This comment has been minimized.

Copy link
Member

schlessera commented Nov 8, 2019

Failed tests are unrelated, merging regardless.

@schlessera schlessera merged commit e397cf2 into wp-cli:master Nov 8, 2019
1 check failed
1 check failed
continuous-integration/travis-ci/pr The Travis CI build failed
Details
@schlessera schlessera changed the title WP-CLI Themes: Added workaround to equalize folder naming conventions across Win/Mac/Linux Equalize theme folder naming conventions across Win/Mac/Linux Nov 8, 2019
@schlessera

This comment has been minimized.

Copy link
Member

schlessera commented Nov 8, 2019

Thanks for the PR, @achyuthajoy & @beaucollins !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.