跳转到主要内容
本章内容101
-
01
References
Argument Syntax - Explanation of the syntax conventions used in command synopsis.
Global parameters - Varia...
8 小时前
-
02
Argument Syntax
WP-CLI commands use a standardized syntax to describe their arguments and options. Understanding this synta...
8 小时前
-
03
Behat Steps
WP-CLI makes use of a Behat-based testing framework and provides a set of custom step definitions to write ...
22 小时前
-
04
Config
WP-CLI has a series of global parameters (e.g.
--path=<path> and
--user=<user>) which work with all comma...
8 小时前
-
05
Documentation Standards
To promote similarity and consistency between WP-CLI commands, we've produced these documentation standards...
8 小时前
-
06
Exit Codes
WP-CLI follows widely-adopted Unix conventions for exit codes:
0 signals success (the command’s primary co...
8 小时前
-
07
Given /^"([^"]+)" replaced with "([^"]+)" in the ([^\s]+) file$/
Search and replace a string in a file using regex.
Usage
Scenario: My example scenario
Given "Foo" replac...
22 小时前
-
08
Given /^a downloaded Phar with (?:the same version|version "([^"]+)")$/
Download a specific WP-CLI Phar version from GitHub.
Usage
Scenario: My example scenario
Given an empty d...
22 小时前
-
09
Given /^a new Phar with (?:the same version|version "([^"]+)")$/
Build a new WP-CLI Phar file with a given version.
Usage
Scenario: My example scenario
Given an empty dir...
22 小时前
-
10
Given /^a WP multisite (subdirectory|subdomain)?\s?(install|installation)$/
Installs WordPress Multisite.
Usage
Supports either subdirectory or subdomain installation.
Scenario: My ex...
22 小时前
-
11
Given /^a WP( [^\s]+)? install(?:ation)? in ['"]?([^'"]+)['"]?$/
Installs WordPress in a given directory.
Usage
Scenario: My example scenario
Given a WP installation in '...
22 小时前
-
12
Given /^a WP( \d[^\s]+)? install(?:ation)?$/
Installs WordPress.
Usage
Scenario: My example scenario
Given a WP installation
...
Scenario: My other ...
22 小时前
-
13
Given /^an? ("[^"]+"|[^\s]+) (file|cache file):$/
Creates a file with the given contents.
Usage
The file can be created either in the current working directo...
22 小时前
-
14
Given /^an? (empty|non-existent) ([^\s]+) directory$/
Creates or deletes a specific directory.
Usage
Scenario: My example scenario
Given an empty foo-plugin di...
22 小时前
-
15
Given /^save (STDOUT|STDERR) ([\'].+[^\'])?\s?as \{(\w+)\}$/
Store STDOUT or STDERR contents in a variable.
Usage
Scenario: My example scenario
When I run `wp package...
22 小时前
-
16
Given /^save the (.+) file ([\'].+[^\'])?as \{(\w+)\}$/
Stores the contents of the given file in a variable.
Usage
Scenario: My example scenario
Given a WP insta...
22 小时前
-
17
Given /^that HTTP requests to (.*?) will respond with:$/
Mock HTTP requests to a given URL.
Usage
Scenario: My example scenario
Given that HTTP requests to https:...
22 小时前
-
18
Given a custom wp-content directory
Configure a custom
wp-content directory.
Usage
Defines the
WP_CONTENT_DIR,
WP_PLUGIN_DIR, and
WPMU_PLUG...
22 小时前
-
19
Given a database
Creates an empty database.
Usage
Has no effect when tests run with SQLite.
Scenario: My example scenario
...
22 小时前
-
20
Given a dependency on current wp-cli
Add
wp-cli/wp-cli as a Composer dependency.
Usage
Scenario: My example scenario
Given a WP installation ...
22 小时前
-
21
Given a misconfigured WP_CONTENT_DIR constant directory
Modify wp-config.php to set
WP_CONTENT_DIR to an empty string.
Usage
Scenario: My example scenario
Given...
22 小时前
-
22
Given a PHP built-in web server
Start a PHP built-in web server in the current directory.
Usage
Scenario: My example scenario
Given a WP ...
22 小时前
-
23
Given a PHP built-in web server to serve :subdir
Start a PHP built-in web server in the given subdirectory.
Usage
Scenario: My example scenario
Given a WP...
22 小时前
-
24
Given a WP install(ation) with Composer
Installs WordPress with Composer.
Usage
Scenario: My example scenario
Given a WP installation with Compos...
22 小时前
-
25
Given a WP install(ation) with Composer and a custom vendor directory :vendor_directory
Installs WordPress with Composer and a custom vendor directory.
Usage
Scenario: My example scenario
Given...
22 小时前
-
26
Given an empty cache
Clears the WP-CLI cache directory.
Usage
Scenario: My example scenario
Given an empty cache
...
Behat s...
22 小时前
-
27
Given an empty directory
Creates an empty directory.
Usage
Scenario: My example scenario
Given an empty directory
...
Behat step...
22 小时前
-
28
Given download:
Download multiple files into the given destinations.
Usage
Scenario: My example scenario
Given download:
...
22 小时前
-
29
Given these installed and active plugins:
Installs and activates one or more plugins.
Usage
Scenario: My example scenario
Given a WP installation
...
22 小时前
-
30
Given WP files
Download WordPress files without installing.
Usage
Scenario: My example scenario
Given an empty directory...
22 小时前
-
31
Given wp-config.php
Create a wp-config.php file using
wp config create.
Usage
Scenario: My example scenario
Given an empty d...
22 小时前
-
32
Hosting Companies
The following is a list of hosting companies that have WP-CLI installed by default for their customers, i.e...
22 小时前
-
33
Internal API
WP-CLI includes a number of utilities which are considered stable and meant to be used by commands.
This al...
22 小时前
-
34
Shell Friends
As you advance upon your use of WP-CLI, you'll find that a little bit of command line knowledge can have a ...
8 小时前
-
35
Then /^(STDOUT|STDERR) should be a number$/
Expect STDOUT or STDERR to be a numeric value.
Usage
Scenario: My example scenario
Given a WP installatio...
22 小时前
-
36
Then /^(STDOUT|STDERR) should be a version string (<|<=|>|>=|==|=|!=|<>) ([+\w.{}-]+)$/
Expect STDOUT or STDERR to be a version string comparing to the given version.
Usage
Scenario: My example s...
22 小时前
-
37
Then /^(STDOUT|STDERR) should be empty$/
Expect STDOUT or STDERR to be empty.
Usage
Scenario: My other scenario
Given a WP install
When I run `w...
22 小时前
-
38
Then /^(STDOUT|STDERR) should not be a number$/
Expect STDOUT or STDERR to not be a numeric value.
Usage
Scenario: My example scenario
Given a WP install...
22 小时前
-
39
Then /^(STDOUT|STDERR) should not be empty$/
Expect STDOUT or STDERR not to be empty.
Usage
Scenario: My example scenario
When I run `wp user create e...
22 小时前
-
40
Then /^(STDOUT|STDERR) should( not)? match (((\/.+\/)|(#.+#))([a-z]+)?)$/
Match STDOUT or STDERR against a regex.
Usage
Scenario: My example scenario
When I run `wp dist-archive w...
22 小时前
-
41
Then /^(STDOUT|STDERR) should( strictly)? (be|contain|not contain):$/
Check the contents of STDOUT or STDERR.
Usage
Scenario: My example scenario
Given an empty directory
Wh...
22 小时前
-
42
Then /^an email should (be sent|not be sent)$/
Expect an email to be sent (or not).
Usage
Scenario: My example scenario
When I run `wp user reset-passwo...
22 小时前
-
43
Then /^STDOUT should be a JSON array containing:$/
Expect valid JSON array output in STDOUT.
Usage
Errors when some items are missing from the expected array....
22 小时前
-
44
Then /^STDOUT should be a table containing rows:$/
Expect STDOUT to be a table containing the given rows.
Usage
Scenario: My example scenario
Given a WP ins...
22 小时前
-
45
Then /^STDOUT should be CSV containing:$/
Expect STDOUT to be CSV containing certain values.
Usage
Scenario: My example scenario
When I run `wp ter...
22 小时前
-
46
Then /^STDOUT should be JSON containing:$/
Expect valid JSON output in STDOUT.
Usage
Scenario: My example scenario
When I run `wp post meta get 1 me...
22 小时前
-
47
Then /^STDOUT should be YAML containing:$/
Expect STDOUT to be YAML containing certain content.
Usage
Scenario: My example scenario
When I run `wp c...
22 小时前
-
48
Then /^STDOUT should end with a table containing rows:$/
Expect STDOUT to end with a table containing the given rows.
Usage
Useful when the table is preceded by som...
22 小时前
-
49
Then /^the (.+) (file|directory) should( strictly)? (exist|not exist|be:|contain:|not contain:)$/
Expect a certain file or directory to (not) exist or (not) contain certain contents.
Usage
Scenario: My exa...
22 小时前
-
50
Then /^the contents of the (.+) file should( not)? match (((\/.+\/)|(#.+#))([a-z]+)?)$/
Match file contents against a regex.
Usage
Scenario: My example scenario
When I run `wp scaffold plugin h...
22 小时前
-
51
Then /^the return code should( not)? be (\d+)$/
Expect a specific exit code of the previous command.
Usage
Scenario: My example scenario
Given a WP insta...
22 小时前
-
52
Then the HTTP status code should be :code
Expect the HTTP status code for visiting
http://localhost:8080.
Usage
Scenario: My example scenario
Give...
22 小时前
-
53
Tools
The following is a list of projects that integrate with WP-CLI in some form. For installable WP-CLI package...
22 小时前
-
54
When /^I (run|try) `([^`]+)` from '([^\s]+)'$/
Run or try a given command in a subdirectory.
Usage
run expects an exit code 0, whereas
try allows for non...
22 小时前
-
55
When /^I (run|try) `([^`]+)`$/
Run or try a given command.
Usage
run expects an exit code 0, whereas
try allows for non-zero exit codes.
...
22 小时前
-
56
When /^I (run|try) the previous command again$/
Run or try the previous command again.
Usage
run expects an exit code 0, whereas
try allows for non-zero e...
22 小时前
-
57
When /^I launch in the background `([^`]+)`$/
Launch a given command in the background.
Usage
Scenario: My example scenario
Given a WP install
And I ...
22 小时前
-
58
WP_CLI::add_command()
Register a command to WP-CLI.
Usage
WP_CLI::add_command( $name, $callable, $args = [] )
$name (string) Name...
22 小时前
-
59
WP_CLI::add_hook()
Schedule a callback to be executed at a certain point.
Usage
WP_CLI::add_hook( $when, $callback )
$when (st...
22 小时前
-
60
WP_CLI::add_wp_hook()
Add a callback to a WordPress action or filter.
Usage
WP_CLI::add_wp_hook( $tag, $function_to_add, $priorit...
22 小时前
-
61
WP_CLI::colorize()
Colorize a string for output.
Usage
WP_CLI::colorize( $string )
$string (string) String to colorize for out...
22 小时前
-
62
WP_CLI::confirm()
Ask for confirmation before running a destructive operation.
Usage
WP_CLI::confirm( $question, $assoc_args ...
22 小时前
-
63
WP_CLI::debug()
Display debug message prefixed with "Debug: " when
--debug is used.
Usage
WP_CLI::debug( $message, $group ...
22 小时前
-
64
WP_CLI::do_hook()
Execute callbacks registered to a given hook.
Usage
WP_CLI::do_hook( $when, $args )
$when (string) Identifi...
22 小时前
-
65
WP_CLI::error()
Display error message prefixed with "Error: " and exit script.
Usage
WP_CLI::error( $message, $exit = true ...
22 小时前
-
66
WP_CLI::error_multi_line()
Display a multi-line error message in a red box. Doesn't exit script.
Usage
WP_CLI::error_multi_line( $mess...
22 小时前
-
67
WP_CLI::get_config()
Get values of global configuration parameters.
Usage
WP_CLI::get_config( $key = null )
$key (string) Get va...
8 小时前
-
68
WP_CLI::get_php_binary()
Get the path to the PHP binary used when executing WP-CLI.
Usage
WP_CLI::get_php_binary()
@return (string) ...
22 小时前
-
69
WP_CLI::halt()
Halt script execution with a specific return code.
Usage
WP_CLI::halt( $return_code )
$return_code (integer...
22 小时前
-
70
WP_CLI::has_config()
Confirm that a global configuration parameter does exist.
Usage
WP_CLI::has_config( $key )
$key (string) Co...
22 小时前
-
71
WP_CLI::launch()
Launch an arbitrary external process that takes over I/O.
Usage
WP_CLI::launch( $command, $exit_on_error = ...
22 小时前
-
72
WP_CLI::launch_self()
Run a WP-CLI command in a new process reusing the current runtime arguments.
Usage
WP_CLI::launch_self( $co...
22 小时前
-
73
WP_CLI::line()
Display informational message without prefix, and ignore
--quiet.
Usage
WP_CLI::line( $message = '', $newl...
22 小时前
-
74
WP_CLI::log()
Display informational message without prefix.
Usage
WP_CLI::log( $message, $newline = true )
$message (stri...
22 小时前
-
75
WP_CLI::read_value()
Read a value, from various formats.
Usage
WP_CLI::read_value( $raw_value, $assoc_args = [] )
$raw_value (st...
22 小时前
-
76
WP_CLI::run_command()
Run a given command within the current process using the same global parameters.
Usage
WP_CLI::run_command(...
22 小时前
-
77
WP_CLI::runcommand()
Run a WP-CLI command.
Usage
WP_CLI::runcommand( $command, $options = [] )
$command (string) WP-CLI command ...
22 小时前
-
78
WP_CLI::success()
Display success message prefixed with "Success: ".
Usage
WP_CLI::success( $message )
$message (string) Mess...
22 小时前
-
79
WP_CLI::warning()
Display warning message prefixed with "Warning: ".
Usage
WP_CLI::warning( $message )
$message (string|WP_Er...
22 小时前
-
80
WP_CLI\Utils\basename()
Locale-independent version of basename()
Usage
WP_CLI\Utils\basename( $path, $suffix = '' )
$path (string) ...
22 小时前
-
81
WP_CLI\Utils\esc_like()
First half of escaping for LIKE special characters % and _ before preparing for MySQL.
Usage
WP_CLI\Utils\e...
22 小时前
-
82
WP_CLI\Utils\format_items()
Render a collection of items as an ASCII table, JSON, CSV, YAML, list of ids, or count.
Usage
WP_CLI\Utils\...
22 小时前
-
83
WP_CLI\Utils\get_flag_value()
Return the flag value or, if it's not set, the $default value.
Usage
WP_CLI\Utils\get_flag_value( $assoc_ar...
22 小时前
-
84
WP_CLI\Utils\get_home_dir()
Get the home directory.
Usage
WP_CLI\Utils\get_home_dir()
@return (string)
Internal API documentation is g...
22 小时前
-
85
WP_CLI\Utils\get_named_sem_ver()
Compare two version strings to get the named semantic version.
Usage
WP_CLI\Utils\get_named_sem_ver( $new_v...
22 小时前
-
86
WP_CLI\Utils\get_php_binary()
Get the path to the PHP binary used when executing WP-CLI.
Usage
WP_CLI\Utils\get_php_binary()
@return (str...
22 小时前
-
87
WP_CLI\Utils\get_temp_dir()
Get the system's temp directory. Warns user if it isn't writable.
Usage
WP_CLI\Utils\get_temp_dir()
@return...
22 小时前
-
88
WP_CLI\Utils\http_request()
Make a HTTP request to a remote URL.
Usage
WP_CLI\Utils\http_request( $method, $url, $data = null, $headers...
22 小时前
-
89
WP_CLI\Utils\is_stream()
Check if a path is a PHP stream URL.
Usage
WP_CLI\Utils\is_stream( $path )
$path (string) The resource path...
22 小时前
-
90
WP_CLI\Utils\isPiped()
Checks whether the output of the current script is a TTY or a pipe / redirect
Usage
WP_CLI\Utils\isPiped()
...
22 小时前
-
91
WP_CLI\Utils\launch_editor_for_input()
Launch system's $EDITOR for the user to edit some text.
Usage
WP_CLI\Utils\launch_editor_for_input( $input,...
22 小时前
-
92
WP_CLI\Utils\make_progress_bar()
Create a progress bar to display percent completion of a given operation.
Usage
WP_CLI\Utils\make_progress_...
22 小时前
-
93
WP_CLI\Utils\make_temp_dir()
Create a unique temporary directory safely without following symlinks.
Usage
WP_CLI\Utils\make_temp_dir( $p...
22 小时前
-
94
WP_CLI\Utils\make_temp_file()
Create a unique temporary file safely without following symlinks.
Usage
WP_CLI\Utils\make_temp_file( $prefi...
22 小时前
-
95
WP_CLI\Utils\normalize_path()
Normalize a filesystem path.
Usage
WP_CLI\Utils\normalize_path( $path )
$path (string) Path to normalize.
@...
22 小时前
-
96
WP_CLI\Utils\parse_ssh_url()
Parse a SSH url for its host, port, and path.
Usage
WP_CLI\Utils\parse_ssh_url( $url, $component = -1 )
$ur...
22 小时前
-
97
WP_CLI\Utils\parse_str_to_argv()
Parse a string of command line arguments into an $argv-esqe variable.
Usage
WP_CLI\Utils\parse_str_to_argv(...
22 小时前
-
98
WP_CLI\Utils\proc_open_compat()
Windows compatible
proc_open(). Works around bug in PHP, and also deals with *nix-like
ENV_VAR=blah cmd e...
22 小时前
-
99
WP_CLI\Utils\report_batch_operation_results()
Report the results of the same operation against multiple resources.
Usage
WP_CLI\Utils\report_batch_operat...
22 小时前
-
100
WP_CLI\Utils\trailingslashit()
Appends a trailing slash.
Usage
WP_CLI\Utils\trailingslashit( $string )
$string (string) What to add the tr...
22 小时前
-
101
WP_CLI\Utils\write_csv()
Write data as CSV to a given file.
Usage
WP_CLI\Utils\write_csv( $fd, $rows, $headers = [] )
$fd (resource)...
22 小时前