{"id":18407,"date":"2025-11-09T20:35:18","date_gmt":"2025-11-09T20:35:18","guid":{"rendered":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/make.wordpress.org\/cli\/handbook\/references\/argument-syntax\/"},"modified":"2026-07-17T00:49:04","modified_gmt":"2026-07-17T00:49:04","slug":"argument-syntax","status":"publish","type":"handbook","link":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/make.wordpress.org\/cli\/handbook\/references\/argument-syntax\/","title":{"rendered":"Argument Syntax"},"content":{"rendered":"<p><span tabindex='0' class='glossary-item-container'>WP-CLI<span class='glossary-item-hidden-content'><span class='glossary-item-header'>WP-CLI<\/span> <span class='glossary-item-description'>WP-CLI is the Command Line Interface for WordPress, used to do administrative and development tasks in a programmatic way. The project page is <a href=\"https:\/\/round-lake.dustinice.workers.dev:443\/http\/wp-cli.org\/\">https:\/\/round-lake.dustinice.workers.dev:443\/http\/wp-cli.org\/<\/a> <a href=\"https:\/\/round-lake.dustinice.workers.dev:443\/https\/make.wordpress.org\/cli\/\">https:\/\/round-lake.dustinice.workers.dev:443\/https\/make.wordpress.org\/cli\/<\/a><\/span><\/span><\/span> commands use a standardized syntax to describe their arguments and options. Understanding this syntax will help you use commands correctly and avoid confusion.<\/p>\n<h2>Syntax Conventions<\/h2>\n<p>The command synopsis uses specific formatting to indicate whether arguments are required or optional, and what type of values they accept.<\/p>\n<h3>Required Arguments<\/h3>\n<p>Arguments without square brackets are <strong>required<\/strong> and must be provided:<\/p>\n<ul>\n<li><strong><code>&lt;argument&gt;<\/code><\/strong> \u2013 A required positional argument that needs a value.\n<ul>\n<li>Example: <code>&lt;hook&gt;<\/code> means you must provide a hook name<\/li>\n<li>Usage: <code>wp cron event schedule my_hook<\/code><\/li>\n<\/ul>\n<\/li>\n<li><strong><code>--option=&lt;value&gt;<\/code><\/strong> \u2013 A required option that needs a value.\n<ul>\n<li>Example: <code>--dbname=&lt;dbname&gt;<\/code> means you must provide the database name<\/li>\n<li>Usage: <code>wp config create --dbname=mydatabase --dbuser=root<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Optional Arguments<\/h3>\n<p>Arguments enclosed in square brackets <strong><code>[ ]<\/code><\/strong> are optional:<\/p>\n<ul>\n<li><strong><code>[&lt;argument&gt;]<\/code><\/strong> \u2013 An optional positional argument.\n<ul>\n<li>Example: <code>[&lt;next-run&gt;]<\/code> means this argument can be omitted<\/li>\n<li>If omitted, a default value may be used<\/li>\n<\/ul>\n<\/li>\n<li><strong><code>[--option=&lt;value&gt;]<\/code><\/strong> \u2013 An optional option that accepts a value.\n<ul>\n<li>Example: <code>[--dbhost=&lt;dbhost&gt;]<\/code> means this option can be omitted<\/li>\n<li>Often has a default value (e.g., <code>localhost<\/code> for <code>--dbhost<\/code>)<\/li>\n<li>Usage: <code>wp config create --dbname=mydb --dbuser=root --dbhost=127.0.0.1<\/code><\/li>\n<\/ul>\n<\/li>\n<li><strong><code>[--flag]<\/code><\/strong> \u2013 An optional boolean flag.\n<ul>\n<li>Example: <code>[--force]<\/code> means this flag can be included or omitted<\/li>\n<li>When present, the flag is <code>true<\/code>; when absent, it\u2019s <code>false<\/code><\/li>\n<li>Usage: <code>wp config create --dbname=mydb --dbuser=root --force<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Boolean Flags<\/h3>\n<p>Boolean flags are switches that enable or disable a feature:<\/p>\n<ul>\n<li><strong>Enabling<\/strong>: Include the flag to set it to <code>true<\/code>\n<ul>\n<li>Example: <code>--force<\/code> enables force mode<\/li>\n<\/ul>\n<\/li>\n<li><strong>Disabling<\/strong>: Most flags can be \u201creversed\u201d with a <code>--no-<\/code> prefix\n<ul>\n<li>Example: <code>--no-force<\/code> explicitly disables force mode<\/li>\n<li>Example: <code>--no-color<\/code> disables color output<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Associative Arguments<\/h3>\n<p>Some commands accept arbitrary key-value pairs:<\/p>\n<ul>\n<li><strong><code>[--&lt;field&gt;=&lt;value&gt;]<\/code><\/strong> \u2013 Accepts any field name with a value.\n<ul>\n<li>Example: <code>--foo=bar --baz=qux<\/code><\/li>\n<li>Useful for passing custom data or configuration<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Repeatable Arguments<\/h3>\n<p>Arguments that can be provided multiple times:<\/p>\n<ul>\n<li><strong><code>[--&lt;field&gt;=&lt;value&gt;]<\/code><\/strong> \u2013 When documented as repeatable, you can provide the option multiple times.\n<ul>\n<li>Example: <code>--require=&lt;path&gt;<\/code> can be used as <code>--require=\/path\/one.php --require=\/path\/two.php<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Variadic Arguments<\/h3>\n<p>Arguments that accept multiple values:<\/p>\n<ul>\n<li><strong><code>&lt;argument&gt;...<\/code><\/strong> \u2013 The ellipsis (<code>...<\/code>) indicates the argument accepts one or more values.\n<ul>\n<li>Example: <code>&lt;file&gt;...<\/code> means you can provide multiple files<\/li>\n<li>Usage: <code>wp plugin install plugin1 plugin2 plugin3<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Value Placeholders<\/h3>\n<p>The text inside angle brackets describes what kind of value is expected:<\/p>\n<ul>\n<li><strong><code>&lt;id&gt;<\/code><\/strong> \u2013 Expects a numeric identifier<\/li>\n<li><strong><code>&lt;file&gt;<\/code><\/strong> \u2013 Expects a file path<\/li>\n<li><strong><code>&lt;url&gt;<\/code><\/strong> \u2013 Expects a <span tabindex='0' class='glossary-item-container'>URL<span class='glossary-item-hidden-content'><span class='glossary-item-header'>URL<\/span> <span class='glossary-item-description'>A specific web address of a website or web page on the Internet, such as a website\u2019s URL www.wordpress.org<\/span><\/span><\/span><\/li>\n<li><strong><code>&lt;name&gt;<\/code><\/strong> \u2013 Expects a name or label<\/li>\n<li><strong><code>&lt;format&gt;<\/code><\/strong> \u2013 Expects a format type (often with available options listed)<\/li>\n<\/ul>\n<h2>Common Patterns<\/h2>\n<h3>Required Database Connection<\/h3>\n<p>Many commands require database connection details:<\/p>\n<pre><code>--dbname=&lt;dbname&gt; --dbuser=&lt;dbuser&gt; [--dbpass=&lt;dbpass&gt;] [--dbhost=&lt;dbhost&gt;]\n<\/code><\/pre>\n<ul>\n<li><code>--dbname<\/code> and <code>--dbuser<\/code> are required<\/li>\n<li><code>--dbpass<\/code> and <code>--dbhost<\/code> are optional<\/li>\n<\/ul>\n<h3>Format Options<\/h3>\n<p>Commands that output data often accept a format option:<\/p>\n<pre><code>[--format=&lt;format&gt;]\n<\/code><\/pre>\n<p>Common formats include: <code>table<\/code>, <code>csv<\/code>, <code>json<\/code>, <code>yaml<\/code>, <code>count<\/code><\/p>\n<h3>Fields and Filtering<\/h3>\n<p>Commands that work with multiple fields:<\/p>\n<pre><code>[--fields=&lt;fields&gt;] [--field=&lt;field&gt;]\n<\/code><\/pre>\n<ul>\n<li><code>--fields<\/code> typically accepts a comma-separated list<\/li>\n<li><code>--field<\/code> typically returns a single field value<\/li>\n<\/ul>\n<h2>Examples<\/h2>\n<p>Here are practical examples showing different syntax types:<\/p>\n<pre><code class=\"language-bash\"># Required arguments (no brackets)\nwp config create --dbname=mydb --dbuser=root\n\n# Optional arguments with defaults\nwp config create --dbname=mydb --dbuser=root --dbhost=localhost\n\n# Boolean flags\nwp plugin install hello-dolly --activate --force\n\n# Negated boolean flags\nwp plugin list --no-color\n\n# Associative arguments\nwp cron event schedule my_hook --foo=bar --baz=qux\n\n# Multiple values\nwp plugin install plugin1 plugin2 plugin3\n\n# Optional fields with specific format options\nwp post list --format=json --fields=ID,post_title,post_date\n<\/code><\/pre>\n<h2>Tips<\/h2>\n<ul>\n<li>Always check the command\u2019s <code>OPTIONS<\/code> section to see which arguments are required<\/li>\n<li>Use <code>wp help &lt;command&gt;<\/code> to see the complete synopsis and documentation<\/li>\n<li>When in doubt about a flag, try the <code>--help<\/code> option: <code>wp &lt;command&gt; --help<\/code><\/li>\n<li>Default values for optional arguments are typically listed in the <code>OPTIONS<\/code> section<\/li>\n<li>Quote values that contain spaces or special characters: <code>--title=\"My Post Title\"<\/code><\/li>\n<\/ul>\n<h2>Related Documentation<\/h2>\n<ul>\n<li><a href=\"https:\/\/round-lake.dustinice.workers.dev:443\/https\/make.wordpress.org\/cli\/handbook\/references\/documentation-standards\/\">Documentation Standards<\/a> \u2013 Standards for annotating WP-CLI commands<\/li>\n<li><a href=\"https:\/\/round-lake.dustinice.workers.dev:443\/https\/make.wordpress.org\/cli\/handbook\/guides\/commands-cookbook\/\">Commands Cookbook<\/a> \u2013 How commands work<\/li>\n<li><a href=\"https:\/\/round-lake.dustinice.workers.dev:443\/https\/make.wordpress.org\/cli\/handbook\/references\/config\/\">Global Parameters<\/a> \u2013 Parameters available to all commands<\/li>\n<\/ul>\n<nav class='o2-post-footer-actions'><ul class='o2-post-footer-action-row'><\/ul><div class='o2-post-footer-action-likes'><\/div><ul class='o2-post-footer-action-row'><\/ul><\/nav>","protected":false},"author":0,"featured_media":0,"parent":18371,"menu_order":0,"template":"","meta":{"footnotes":""},"class_list":["post-18407","handbook","type-handbook","status-publish","hentry","make-argument-syntax"],"revision_note":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/make.wordpress.org\/cli\/wp-json\/wp\/v2\/handbook\/18407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/make.wordpress.org\/cli\/wp-json\/wp\/v2\/handbook"}],"about":[{"href":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/make.wordpress.org\/cli\/wp-json\/wp\/v2\/types\/handbook"}],"version-history":[{"count":1,"href":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/make.wordpress.org\/cli\/wp-json\/wp\/v2\/handbook\/18407\/revisions"}],"predecessor-version":[{"id":18408,"href":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/make.wordpress.org\/cli\/wp-json\/wp\/v2\/handbook\/18407\/revisions\/18408"}],"up":[{"embeddable":true,"href":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/make.wordpress.org\/cli\/wp-json\/wp\/v2\/handbook\/18371"}],"wp:attachment":[{"href":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/make.wordpress.org\/cli\/wp-json\/wp\/v2\/media?parent=18407"}],"curies":[{"name":"wp","href":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/api.w.org\/{rel}","templated":true}]}}