Skip to content

Commit 7fa9836

Browse files
Merge pull request #31 from wp-cli/update-scaffold
Update package with latest scaffolded components
2 parents 8574ba7 + 63b4719 commit 7fa9836

16 files changed

+888
-123
lines changed

.github/ISSUE_TEMPLATE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!--
2+
3+
Thanks for creating a new issue!
4+
5+
Found a bug or want to suggest an enhancement? Before completing your issue, please review our best practices: https://make.wordpress.org/cli/handbook/bug-reports/
6+
7+
Need help with something? GitHub issues aren't for general support questions, but there are other venues you can try: https://wp-cli.org/#support
8+
9+
You can safely delete this comment.
10+
11+
-->

.github/PULL_REQUEST_TEMPLATE

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!--
2+
3+
Thanks for submitting a pull request!
4+
5+
Here's an overview to our process:
6+
7+
1. One of the project committers will soon provide a code review.
8+
2. You are expected to address the code review comments in a timely manner.
9+
3. Please make sure to include functional tests for your changes.
10+
4. The reviewing committer will merge your pull request as soon as it passes code review (and provided it fits within the scope of the project).
11+
12+
You can safely delete this comment.
13+
14+
-->

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.DS_Store
22
wp-cli.local.yml
3-
composer.lock
43
node_modules/
54
vendor/
65
*.zip

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ matrix:
2929
env: WP_VERSION=latest
3030
- php: 5.6
3131
env: WP_VERSION=latest
32+
- php: 5.6
33+
env: WP_VERSION=3.7.11
3234
- php: 5.6
3335
env: WP_VERSION=trunk
3436
- php: 5.3
@@ -46,4 +48,4 @@ before_script:
4648
- composer validate
4749

4850
script:
49-
- behat --format progress --strict
51+
- bash bin/test.sh

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Contributing
2+
============
3+
4+
We appreciate you taking the initiative to contribute to this project.
5+
6+
Contributing isn’t limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.
7+
8+
For a more thorough introduction, [check out WP-CLI's guide to contributing](https://make.wordpress.org/cli/handbook/contributing/). This package follows those policy and guidelines.

README.md

Lines changed: 160 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Perform basic database operations using credentials stored in wp-config.php.
55

66
[![Build Status](https://travis-ci.org/wp-cli/db-command.svg?branch=master)](https://travis-ci.org/wp-cli/db-command)
77

8-
Quick links: [Using](#using) | [Installing](#installing) | [Contributing](#contributing)
8+
Quick links: [Using](#using) | [Installing](#installing) | [Contributing](#contributing) | [Support](#support)
99

1010
## Using
1111

@@ -16,7 +16,7 @@ This package implements the following commands:
1616
Create a new database.
1717

1818
~~~
19-
wp db create
19+
wp db create
2020
~~~
2121

2222
Runs `CREATE_DATABASE` SQL statement using `DB_HOST`, `DB_NAME`,
@@ -83,7 +83,7 @@ specified in wp-config.php.
8383
Check the current status of the database.
8484

8585
~~~
86-
wp db check
86+
wp db check
8787
~~~
8888

8989
Runs `mysqlcheck` utility with `--check` using `DB_HOST`,
@@ -105,7 +105,7 @@ for more details on the `CHECK TABLE` statement.
105105
Optimize the database.
106106

107107
~~~
108-
wp db optimize
108+
wp db optimize
109109
~~~
110110

111111
Runs `mysqlcheck` utility with `--optimize=true` using `DB_HOST`,
@@ -120,14 +120,31 @@ for more details on the `OPTIMIZE TABLE` statement.
120120
$ wp db optimize
121121
Success: Database optimized.
122122

123-
*Note:* `wp db optimize` optimizes the entire database, including non-WordPress tables. [See #24](https://github.com/wp-cli/db-command/issues/24)
123+
124+
125+
### wp db prefix
126+
127+
Display the database table prefix.
128+
129+
~~~
130+
wp db prefix
131+
~~~
132+
133+
Display the database table prefix, as defined by the database handler's interpretation of the current site.
134+
135+
**EXAMPLES**
136+
137+
$ wp db prefix
138+
wp_
139+
140+
124141

125142
### wp db repair
126143

127144
Repair the database.
128145

129146
~~~
130-
wp db repair
147+
wp db repair
131148
~~~
132149

133150
Runs `mysqlcheck` utility with `--repair=true` using `DB_HOST`,
@@ -311,6 +328,136 @@ defined in the SQL.
311328

312329

313330

331+
### wp db search
332+
333+
Find a string in the database.
334+
335+
~~~
336+
wp db search <search> [<tables>...] [--network] [--all-tables-with-prefix] [--all-tables] [--before_context=<num>] [--after_context=<num>] [--regex] [--regex-flags=<regex-flags>] [--regex-delimiter=<regex-delimiter>] [--table_column_once] [--one_line] [--matches_only] [--stats] [--table_column_color=<color_code>] [--id_color=<color_code>] [--match_color=<color_code>]
337+
~~~
338+
339+
Searches through all or a selection of database tables for a given string, Outputs colorized references to the string.
340+
341+
Defaults to searching through all tables registered to $wpdb. On multisite, this default is limited to the tables for the current site.
342+
343+
**OPTIONS**
344+
345+
<search>
346+
String to search for. The search is case-insensitive by default.
347+
348+
[<tables>...]
349+
One or more tables to search through for the string.
350+
351+
[--network]
352+
Search through all the tables registered to $wpdb in a multisite install.
353+
354+
[--all-tables-with-prefix]
355+
Search through all tables that match the registered table prefix, even if not registered on $wpdb. On one hand, sometimes plugins use tables without registering them to $wpdb. On another hand, this could return tables you don't expect. Overrides --network.
356+
357+
[--all-tables]
358+
Search through ALL tables in the database, regardless of the prefix, and even if not registered on $wpdb. Overrides --network and --all-tables-with-prefix.
359+
360+
[--before_context=<num>]
361+
Number of characters to display before the match.
362+
---
363+
default: 40
364+
---
365+
366+
[--after_context=<num>]
367+
Number of characters to display after the match.
368+
---
369+
default: 40
370+
---
371+
372+
[--regex]
373+
Runs the search as a regular expression (without delimiters). The search becomes case-sensitive (i.e. no PCRE flags are added, except 'u' if the database charset is UTF-8). Delimiters must be escaped if they occur in the expression.
374+
375+
[--regex-flags=<regex-flags>]
376+
Pass PCRE modifiers to the regex search (e.g. 'i' for case-insensitivity). Note that 'u' (UTF-8 mode) will not be automatically added.
377+
378+
[--regex-delimiter=<regex-delimiter>]
379+
The delimiter to use for the regex. It must be escaped if it appears in the search string.
380+
---
381+
default: /
382+
---
383+
384+
[--table_column_once]
385+
Output the 'table:column' line once before all matching row lines in the table column rather than before each matching row.
386+
387+
[--one_line]
388+
Place the 'table:column' output on the same line as the row id and match ('table:column:id:match'). Overrides --table_column_once.
389+
390+
[--matches_only]
391+
Only output the string matches (including context). No 'table:column's or row ids are outputted.
392+
393+
[--stats]
394+
Output stats on the number of matches found, time taken, tables/columns/rows searched, tables skipped.
395+
396+
[--table_column_color=<color_code>]
397+
Percent color code to use for the 'table:column' output. For a list of available percent color codes, see below. Default '%G' (bright green).
398+
399+
[--id_color=<color_code>]
400+
Percent color code to use for the row id output. For a list of available percent color codes, see below. Default '%Y' (bright yellow).
401+
402+
[--match_color=<color_code>]
403+
Percent color code to use for the match (unless both before and after context are 0, when no color code is used). For a list of available percent color codes, see below. Default '%3%k' (black on a mustard background).
404+
405+
The percent color codes available are:
406+
'%y' Yellow (dark) (mustard)
407+
'%g' Green (dark)
408+
'%b' Blue (dark)
409+
'%r' Red (dark)
410+
'%m' Magenta (dark)
411+
'%c' Cyan (dark)
412+
'%w' White (dark) (light gray)
413+
'%k' Black
414+
'%Y' Yellow (bright)
415+
'%G' Green (bright)
416+
'%B' Blue (bright)
417+
'%R' Red (bright)
418+
'%M' Magenta (bright)
419+
'%C' Cyan (bright)
420+
'%W' White
421+
'%K' Black (bright) (dark gray)
422+
'%3' Yellow background (dark) (mustard)
423+
'%2' Green background (dark)
424+
'%4' Blue background (dark)
425+
'%1' Red background (dark)
426+
'%5' Magenta background (dark)
427+
'%6' Cyan background (dark)
428+
'%7' White background (dark) (light gray)
429+
'%0' Black background
430+
'%8' Reverse
431+
'%U' Underline
432+
'%F' Blink (unlikely to work)
433+
They can be concatenated. For instance, the default match color of black on a mustard (dark yellow) background '%3%k' can be made black on a bright yellow background with '%Y%0%8'.
434+
435+
**EXAMPLES**
436+
437+
# Search through the database for the 'wordpress-develop' string
438+
$ wp db search wordpress-develop
439+
wp_options:option_value
440+
1:http://wordpress-develop.dev
441+
wp_options:option_value
442+
1:http://example.com/foo
443+
...
444+
445+
# Search through a multisite database on the subsite 'foo' for the 'example.com' string
446+
$ wp db search example.com --url=example.com/foo
447+
wp_2_comments:comment_author_url
448+
1:http://example.com/
449+
wp_2_options:option_value
450+
...
451+
452+
# Search through the database for the 'https?://' regular expression, printing stats.
453+
$ wp db search 'https?:\/\/' --regex --stats
454+
wp_comments:comment_author_url
455+
1:https://wordpress.org/
456+
...
457+
Success: Found 99146 matches in 10.752s (10.559s searching). Searched 12 tables, 53 columns, 1358907 rows. 1 table skipped: wp_term_relationships.
458+
459+
460+
314461
### wp db tables
315462

316463
List the database tables.
@@ -451,21 +598,6 @@ The size defaults to a human-readable number.
451598
$ wp db size --size_format=mb
452599
6
453600

454-
### wp db prefix
455-
456-
Display the database table prefix.
457-
458-
~~~
459-
wp db prefix
460-
~~~
461-
462-
Display the database table prefix, as defined by the database handler's interpretation of the current site.
463-
464-
**EXAMPLES**
465-
466-
$ wp db prefix
467-
wp_
468-
469601
## Installing
470602

471603
This package is included with WP-CLI itself, no additional installation necessary.
@@ -480,30 +612,25 @@ We appreciate you taking the initiative to contribute to this project.
480612

481613
Contributing isn’t limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.
482614

615+
For a more thorough introduction, [check out WP-CLI's guide to contributing](https://make.wordpress.org/cli/handbook/contributing/). This package follows those policy and guidelines.
616+
483617
### Reporting a bug
484618

485619
Think you’ve found a bug? We’d love for you to help us get it fixed.
486620

487621
Before you create a new issue, you should [search existing issues](https://github.com/wp-cli/db-command/issues?q=label%3Abug%20) to see if there’s an existing resolution to it, or if it’s already been fixed in a newer version.
488622

489-
Once you’ve done a bit of searching and discovered there isn’t an open or fixed issue for your bug, please [create a new issue](https://github.com/wp-cli/db-command/issues/new) with the following:
490-
491-
1. What you were doing (e.g. "When I run `wp post list`").
492-
2. What you saw (e.g. "I see a fatal about a class being undefined.").
493-
3. What you expected to see (e.g. "I expected to see the list of posts.")
494-
495-
Include as much detail as you can, and clear steps to reproduce if possible.
623+
Once you’ve done a bit of searching and discovered there isn’t an open or fixed issue for your bug, please [create a new issue](https://github.com/wp-cli/db-command/issues/new). Include as much detail as you can, and clear steps to reproduce if possible. For more guidance, [review our bug report documentation](https://make.wordpress.org/cli/handbook/bug-reports/).
496624

497625
### Creating a pull request
498626

499627
Want to contribute a new feature? Please first [open a new issue](https://github.com/wp-cli/db-command/issues/new) to discuss whether the feature is a good fit for the project.
500628

501-
Once you've decided to commit the time to seeing your pull request through, please follow our guidelines for creating a pull request to make sure it's a pleasant experience:
629+
Once you've decided to commit the time to seeing your pull request through, [please follow our guidelines for creating a pull request](https://make.wordpress.org/cli/handbook/pull-requests/) to make sure it's a pleasant experience. See "[Setting up](https://make.wordpress.org/cli/handbook/pull-requests/#setting-up)" for details specific to working on this package locally.
630+
631+
## Support
502632

503-
1. Create a feature branch for each contribution.
504-
2. Submit your pull request early for feedback.
505-
3. Include functional tests with your changes. [Read the WP-CLI documentation](https://wp-cli.org/docs/pull-requests/#functional-tests) for an introduction.
506-
4. Follow the [WordPress Coding Standards](http://make.wordpress.org/core/handbook/coding-standards/).
633+
Github issues aren't for general support questions, but there are other venues you can try: http://wp-cli.org/#support
507634

508635

509636
*This README.md is generated dynamically from the project's codebase using `wp scaffold package-readme` ([doc](https://github.com/wp-cli/scaffold-package-command#wp-scaffold-package-readme)). To suggest changes, please submit a pull request against the corresponding part of the codebase.*

bin/test.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
# Run the unit tests, if they exist
6+
if [ -f "phpunit.xml" ] || [ -f "phpunit.xml.dist" ]
7+
then
8+
phpunit
9+
fi
10+
11+
# Run the functional tests
12+
BEHAT_TAGS=$(php utils/behat-tags.php)
13+
behat --format progress $BEHAT_TAGS --strict

0 commit comments

Comments
 (0)