diff --git a/cleo/commands/list_command.py b/cleo/commands/list_command.py index 57be3066..b520d66c 100644 --- a/cleo/commands/list_command.py +++ b/cleo/commands/list_command.py @@ -37,7 +37,10 @@ def handle(self) -> int: from cleo.descriptors.text_descriptor import TextDescriptor TextDescriptor().describe( - self._io, self.application, namespace=self.argument("namespace") + self._io, + self.application, + namespace=self.argument("namespace"), + definition=self.definition, ) return 0 diff --git a/cleo/descriptors/text_descriptor.py b/cleo/descriptors/text_descriptor.py index b053ad4b..48afbc5e 100644 --- a/cleo/descriptors/text_descriptor.py +++ b/cleo/descriptors/text_descriptor.py @@ -164,6 +164,7 @@ def _describe_application(self, application: Application, **options: Any) -> Non described_namespace = options.get("namespace") description = ApplicationDescription(application, namespace=described_namespace) + definition = options.pop("definition", application.definition) help_text = application.help if help_text: @@ -172,7 +173,7 @@ def _describe_application(self, application: Application, **options: Any) -> Non self._write("Usage:\n") self._write(" command [options] [arguments]\n\n") - self._describe_definition(Definition(application.definition.options), **options) + self._describe_definition(Definition(definition.options), **options) self._write("\n") self._write("\n") diff --git a/tests/fixtures/application_run1.txt b/tests/fixtures/application_run1.txt index 94356a39..7a19fa39 100644 --- a/tests/fixtures/application_run1.txt +++ b/tests/fixtures/application_run1.txt @@ -4,6 +4,7 @@ Usage: command [options] [arguments] Options: + -V, --version Display this application version. -h, --help Display help for the given command. When no command is given display help for the list command. -q, --quiet Do not output any message. --ansi Force ANSI output.