Skip to content

Commit ea49ea8

Browse files
committed
minor #21309 Document that usages may be supplied by AsCommand Attribute (weitzman)
This PR was squashed before being merged into the 7.4 branch. Discussion ---------- Document that usages may be supplied by AsCommand Attribute Commits ------- 6829e31 Document that usages may be supplied by AsCommand Attribute
2 parents 73daad1 + 6829e31 commit ea49ea8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

console.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,13 @@ If you can't use PHP attributes, register the command as a service and
147147
:ref:`default services.yaml configuration <service-container-services-load-example>`,
148148
this is already done for you, thanks to :ref:`autoconfiguration <services-autoconfigure>`.
149149

150-
You can also use ``#[AsCommand]`` to add a description and longer help text for the command::
150+
You can also use ``#[AsCommand]`` to add a description, usages, and longer help text for the command::
151151

152152
#[AsCommand(
153153
name: 'app:create-user',
154154
description: 'Creates a new user.', // the command description shown when running "php bin/console list"
155155
help: 'This command allows you to create a user...', // the command help shown when running the command with the "--help" option
156+
usages: ['app:create-user alice'],
156157
)]
157158
class CreateUserCommand
158159
{
@@ -162,6 +163,10 @@ You can also use ``#[AsCommand]`` to add a description and longer help text for
162163
}
163164
}
164165

166+
.. versionadded:: 7.4
167+
168+
The ability to add usages via a ``$usages`` property was introduced in Symfony 7.4.
169+
165170
Additionally, you can extend the :class:`Symfony\\Component\\Console\\Command\\Command` class to
166171
leverage advanced features like lifecycle hooks (e.g. :method:`Symfony\\Component\\Console\\Command\\Command::initialize` and
167172
and :method:`Symfony\\Component\\Console\\Command\\Command::interact`)::

0 commit comments

Comments
 (0)