Title: Command-line syntax
Author: WordPress.org
Published: March 2, 2021
Last modified: April 8, 2021

---

# Command-line syntax

## In this article

 * [Command prompt](https://make.wordpress.org/docs/style-guide/developer-content/command-line-syntax/?output_format=md#command-prompt)
 * [Required commands and arguments](https://make.wordpress.org/docs/style-guide/developer-content/command-line-syntax/?output_format=md#required-commands-and-arguments)
 * [Optional arguments](https://make.wordpress.org/docs/style-guide/developer-content/command-line-syntax/?output_format=md#optional-arguments)
 * [Mutually exclusive arguments](https://make.wordpress.org/docs/style-guide/developer-content/command-line-syntax/?output_format=md#mutually-exclusive-arguments)
 * [Multiple value arguments](https://make.wordpress.org/docs/style-guide/developer-content/command-line-syntax/?output_format=md#multiple-value-arguments)
 * [Command output](https://make.wordpress.org/docs/style-guide/developer-content/command-line-syntax/?output_format=md#command-output)
 * [Additional resources](https://make.wordpress.org/docs/style-guide/developer-content/command-line-syntax/?output_format=md#additional-resources)

[↑ Back to top](https://make.wordpress.org/docs/style-guide/developer-content/command-line-syntax/?output_format=md#wp--skip-link--target)

 **Highlight:** Follow proper command-line syntax and formatting.

This page explains how to format commands and their arguments in documentation. 
For more information about other code-related documentation, see [Code in text](https://make.wordpress.org/docs/style-guide/developer-content/code-in-text/),
[Placeholders](https://make.wordpress.org/docs/style-guide/developer-content/placeholders/),
and [Code examples](https://make.wordpress.org/docs/style-guide/developer-content/code-examples/).

## 󠀁[Command prompt](https://make.wordpress.org/docs/style-guide/developer-content/command-line-syntax/?output_format=md#command-prompt)󠁿

When you have to show multiple lines of command-line input, initiate each line with
the dollar (`$`) command prompt symbol.

Don’t show the current directory path before the prompt, even if part of the instruction
includes creating or changing directories. This is because the directory structure
might be different for the user. However, if the general context of the command-
line interface changes—such as from the local machine to a remote machine—then add
an additional prompt indicator for the new context.

**Examples**

 **Recommended:**

    ```notranslate
    <br />
    $ wp theme activate twentytwentyone<br />
    ```

The output is the following:

    ```notranslate
    <br />
    Success: Switched to &#039;Twenty Twenty-One&#039; theme.<br />
    ```

 **Recommended:**

    ```notranslate
    <br />
    $ pwd<br />
    /srv/www/wordpress-develop.dev<br />
    $ cat wp-cli.yml<br />
    path: src/<br />
    ```

For single-line commands, the command prompt, that is the dollar symbol (`$`) is
optional. However, if you have to show both multi-line and single-line commands,
use the command prompt symbol for overall consistency.

Use separate code blocks for command-line instructions that include both input and
output lines.

**Example**

 **Recommended:**

    ```notranslate
    <br />
    $ wp cap list &#039;editor&#039; | xargs wp cap add &#039;author&#039;<br />
    ```

The output is the following:

    ```notranslate
    <br />
    Success: Added 24 capabilities to &#039;author&#039; role.<br />
    ```

## 󠀁[Required commands and arguments](https://make.wordpress.org/docs/style-guide/developer-content/command-line-syntax/?output_format=md#required-commands-and-arguments)󠁿

When writing commands and arguments that are required, use code font without brackets,
braces, or parentheses.

**Examples**

 **Recommended:**

    ```notranslate
    <br />
    $ wp post list &#8211;post_type=&#039;page&#039; &#8211;format=ids<br />
    ```

 **Recommended:**

    ```notranslate
    <br />
    $ wp core check-update<br />
    ```

 
 In these examples, all words and arguments are required.

For more information, see [Anatomy of a command](https://make.wordpress.org/cli/handbook/guides/commands-cookbook/#anatomy-of-a-command).

## 󠀁[Optional arguments](https://make.wordpress.org/docs/style-guide/developer-content/command-line-syntax/?output_format=md#optional-arguments)󠁿

When writing arguments that are optional, enclose the arguments in square brackets.
If there is more than one optional argument, enclose each item in its individual
set of square brackets.

**Example**

 **Recommended:**

    ```notranslate
    <br />
    $ wp plugin install https://wordpress.org/plugins/gutenberg/ [&#8211;force] [&#8211;activate]<br />
    ```

 
 In this example, `install` is required, but `[--force]` and `[--activate]` are
optional arguments.

## 󠀁[Mutually exclusive arguments](https://make.wordpress.org/docs/style-guide/developer-content/command-line-syntax/?output_format=md#mutually-exclusive-arguments)󠁿

When writing commands where the use has to choose one item, enclose the items in
angle brackets (`<>`; also known as _inequality signs_). Sometimes the mutually 
exclusive choices are also enclosed in braces (also known as _curly braces_). Use
vertical bars (also knows as _pipes_) to separate the items. You can have more than
two mutually exclusive items that are separated from each other by pipes.

**Example**

 **Recommended:**

    ```notranslate
    <br />
    $ wp plugin install &lt;plugin|zip|url&gt;<br />
    ```

 
 In this example, `install` is required, and `<plugin|zip|url>` is the accepted
positional argument. In fact, `wp plugin install` accepts the same positional argument(
the slug, ZIP, or URLURL A specific web address of a website or web page on the 
Internet, such as a website’s URL www.wordpress.org of a pluginPlugin A plugin is
a piece of software containing a group of functions that can be added to a WordPress
website. They can extend functionality or add new features to your WordPress websites.
WordPress plugins are written in the PHP programming language and integrate seamlessly
with WordPress. These can be free in the WordPress.org Plugin Directory [https://wordpress.org/plugins/](https://wordpress.org/plugins/)
or can be cost-based plugin from a third-party. to install). The `plugin`, `zip`,
and `url` choices are mutually exclusive, but one of the argument must be specified.

## 󠀁[Multiple value arguments](https://make.wordpress.org/docs/style-guide/developer-content/command-line-syntax/?output_format=md#multiple-value-arguments)󠁿

Use an ellipsis (`...`) to indicate that the user can specify multiple values for
the argument.

**Examples**

 **Recommended:**

    ```notranslate
    <br />
    $ wp media import [&#8211;post_id=&lt;post_id&gt;&#8230;]<br />
    ```

 
 In this example, the ellipsis indicates that the user can specify multiple instances
of the optional argument `[--post_id=<post_id>]`.

 **Recommended:**

    ```notranslate
    <br />
    $ wp plugin install &lt;plugin|zip|url&gt;&#8230;<br />
    ```

 
 In this example, the ellipsis indicates that the user can specify multiple plugins,
zip files or URLs.

## 󠀁[Command output](https://make.wordpress.org/docs/style-guide/developer-content/command-line-syntax/?output_format=md#command-output)󠁿

You don’t have to show an output for every command. Only add the output if it is
useful; for example, if the user needs to copy a value or needs to verify a value
from the output.

If you do show have to show an output, use an introductory phrase to separate the
command from the output.

**Examples**

 **Recommended:**

    ```notranslate
    <br />
    $ wp theme status twentytwentyone<br />
    ```

The output is the following:

    ```notranslate
    <br />
    Theme twentytwentyone details:<br />
         Name: Twenty Twenty-One<br />
         Status: Active<br />
         Version: 1.1<br />
         Author: WordPress.org<br />
    ```

 **Recommended:**

    ```notranslate
    <br />
    $ wp server &#8211;host=localhost.localdomain &#8211;port=80<br />
    ```

The output is similar to the following:

    ```notranslate
    <br />
    PHP 5.6.9 Development Server started at Fri Jan 22 11:32:56 2021<br />
    Listening on http://localhost1.localdomain1:80<br />
    Document root is /<br />
    Press Ctrl-C to quit.<br />
    ```

For more information about explaining placeholders in output, see [Placeholders in output](https://make.wordpress.org/docs/style-guide/developer-content/placeholders/#placeholders-in-output).

## 󠀁[Additional resources](https://make.wordpress.org/docs/style-guide/developer-content/command-line-syntax/?output_format=md#additional-resources)󠁿

 * [WP-CLI Handbook](https://make.wordpress.org/cli/handbook/)
 * [WP-CLI Commands](https://developer.wordpress.org/cli/commands/)

First published

March 2, 2021

Last updated

April 8, 2021

Edit article

[ Improve it on GitHub: [article_title] ](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fmake.wordpress.org%2Fdocs%2Fstyle-guide%2Fdeveloper-content%2Fcommand-line-syntax%2F&locale=en_US)

Changelog

[ See list of changes: [article_title] ](https://make.wordpress.org/docs/style-guide/developer-content/command-line-syntax/?output_format=md#)

[  Previous: Coding standards](https://make.wordpress.org/docs/style-guide/developer-content/coding-standards/)

[  Next: Placeholders](https://make.wordpress.org/docs/style-guide/developer-content/placeholders/)