Repository: celery/celery

Issue:
Adding new command-line options no longer works
<!--
Please fill this template entirely and do not erase parts of it.
We reserve the right to close without a response
bug reports which are incomplete.
-->
# Checklist
<!--
To check an item on the list replace [ ] with [x].
-->

- [x] I have checked the [issues list](https://github.com/celery/celery/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22Category%3A+Documentation%22+)
  for similar or identical bug reports.
- [x] I have checked the [pull requests list](https://github.com/celery/celery/pulls?q=is%3Apr+label%3A%22Category%3A+Documentation%22)
  for existing proposed fixes.
- [x] I have checked the [commit log](https://github.com/celery/celery/commits/master)
  to find out if the bug was already fixed in the master branch.
- [x] I have included all related issues and possible duplicate issues in this issue
      (If there are none, check this box anyway).

## Related Issues and Possible Duplicates
<!--
Please make sure to search and mention any related issues
or possible duplicates to this issue as requested by the checklist above.

This may or may not include issues in other repositories that the Celery project
maintains or other repositories that are dependencies of Celery.

If you don't know how to mention issues, please refer to Github's documentation
on the subject: https://help.github.com/en/articles/autolinked-references-and-urls#issues-and-pull-requests
-->



# Description
https://docs.celeryproject.org/en/stable/userguide/extending.html#extending-commandoptions

The described code no longer works in celery 5+


Looking at celery's source code, 'user_options' are now expected to be a set(). In fact they are initialized to a defaultdict(set())

I believe that one should provide a click.option, but when i tried that things still fell apart as click is later accessing whatever is provided.opts

# Suggestions
<!-- Please provide us suggestions for how to fix the documentation -->
Upgrade the documentation to support click or modify the code to allow the above example to work
Adding new command-line options no longer works
<!--
Please fill this template entirely and do not erase parts of it.
We reserve the right to close without a response
bug reports which are incomplete.
-->
# Checklist
<!--
To check an item on the list replace [ ] with [x].
-->

- [x] I have checked the [issues list](https://github.com/celery/celery/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22Category%3A+Documentation%22+)
  for similar or identical bug reports.
- [x] I have checked the [pull requests list](https://github.com/celery/celery/pulls?q=is%3Apr+label%3A%22Category%3A+Documentation%22)
  for existing proposed fixes.
- [x] I have checked the [commit log](https://github.com/celery/celery/commits/master)
  to find out if the bug was already fixed in the master branch.
- [x] I have included all related issues and possible duplicate issues in this issue
      (If there are none, check this box anyway).

## Related Issues and Possible Duplicates
<!--
Please make sure to search and mention any related issues
or possible duplicates to this issue as requested by the checklist above.

This may or may not include issues in other repositories that the Celery project
maintains or other repositories that are dependencies of Celery.

If you don't know how to mention issues, please refer to Github's documentation
on the subject: https://help.github.com/en/articles/autolinked-references-and-urls#issues-and-pull-requests
-->



# Description
https://docs.celeryproject.org/en/stable/userguide/extending.html#extending-commandoptions

The described code no longer works in celery 5+


Looking at celery's source code, 'user_options' are now expected to be a set(). In fact they are initialized to a defaultdict(set())

I believe that one should provide a click.option, but when i tried that things still fell apart as click is later accessing whatever is provided.opts

# Suggestions
<!-- Please provide us suggestions for how to fix the documentation -->
Upgrade the documentation to support click or modify the code to allow the above example to work


Discussion:

Resolving patch:
diff --git a/celery/bin/celery.py b/celery/bin/celery.py
--- a/celery/bin/celery.py
+++ b/celery/bin/celery.py
@@ -7,6 +7,8 @@
 import click.exceptions
 from click.types import ParamType
 from click_didyoumean import DYMGroup
+from click_plugins import with_plugins
+from pkg_resources import iter_entry_points
 
 from celery import VERSION_BANNER
 from celery.app.utils import find_app
@@ -69,6 +71,7 @@ def convert(self, value, param, ctx):
 APP = App()
 
 
+@with_plugins(iter_entry_points('celery.commands'))
 @click.group(cls=DYMGroup, invoke_without_command=True)
 @click.option('-A',
               '--app',


Test patch: