We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Duplicate param 'uid' in CeleryDaemonCommand

# Checklist

- [ 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

#### Related Issues

- None

#### Possible Duplicates

- None

# Description

CeleryDaemonCommand have duplicated CeleryOption for --uid which leads to all docs using it to have duplicated line (beat, multi, worker, etc).

# Suggestions

Remove the duplicate in CeleryDaemonCommand in celery/celery/bin/base.py 


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `celery/bin/base.py`
Content:
```
1 """Click customizations for Celery."""
2 import json
3 import numbers
4 from collections import OrderedDict
5 from functools import update_wrapper
6 from pprint import pformat
7 
8 import click
9 from click import ParamType
10 from kombu.utils.objects import cached_property
11 
12 from celery._state import get_current_app
13 from celery.signals import user_preload_options
14 from celery.utils import text
15 from celery.utils.log import mlevel
16 from celery.utils.time import maybe_iso8601
17 
18 try:
19     from pygments import highlight
20     from pygments.formatters import Terminal256Formatter
21     from pygments.lexers import PythonLexer
22 except ImportError:
23     def highlight(s, *args, **kwargs):
24         """Place holder function in case pygments is missing."""
25         return s
26     LEXER = None
27     FORMATTER = None
28 else:
29     LEXER = PythonLexer()
30     FORMATTER = Terminal256Formatter()
31 
32 
33 class CLIContext:
34     """Context Object for the CLI."""
35 
36     def __init__(self, app, no_color, workdir, quiet=False):
37         """Initialize the CLI context."""
38         self.app = app or get_current_app()
39         self.no_color = no_color
40         self.quiet = quiet
41         self.workdir = workdir
42 
43     @cached_property
44     def OK(self):
45         return self.style("OK", fg="green", bold=True)
46 
47     @cached_property
48     def ERROR(self):
49         return self.style("ERROR", fg="red", bold=True)
50 
51     def style(self, message=None, **kwargs):
52         if self.no_color:
53             return message
54         else:
55             return click.style(message, **kwargs)
56 
57     def secho(self, message=None, **kwargs):
58         if self.no_color:
59             kwargs['color'] = False
60             click.echo(message, **kwargs)
61         else:
62             click.secho(message, **kwargs)
63 
64     def echo(self, message=None, **kwargs):
65         if self.no_color:
66             kwargs['color'] = False
67             click.echo(message, **kwargs)
68         else:
69             click.echo(message, **kwargs)
70 
71     def error(self, message=None, **kwargs):
72         kwargs['err'] = True
73         if self.no_color:
74             kwargs['color'] = False
75             click.echo(message, **kwargs)
76         else:
77             click.secho(message, **kwargs)
78 
79     def pretty(self, n):
80         if isinstance(n, list):
81             return self.OK, self.pretty_list(n)
82         if isinstance(n, dict):
83             if 'ok' in n or 'error' in n:
84                 return self.pretty_dict_ok_error(n)
85             else:
86                 s = json.dumps(n, sort_keys=True, indent=4)
87                 if not self.no_color:
88                     s = highlight(s, LEXER, FORMATTER)
89                 return self.OK, s
90         if isinstance(n, str):
91             return self.OK, n
92         return self.OK, pformat(n)
93 
94     def pretty_list(self, n):
95         if not n:
96             return '- empty -'
97         return '\n'.join(
98             f'{self.style("*", fg="white")} {item}' for item in n
99         )
100 
101     def pretty_dict_ok_error(self, n):
102         try:
103             return (self.OK,
104                     text.indent(self.pretty(n['ok'])[1], 4))
105         except KeyError:
106             pass
107         return (self.ERROR,
108                 text.indent(self.pretty(n['error'])[1], 4))
109 
110     def say_chat(self, direction, title, body='', show_body=False):
111         if direction == '<-' and self.quiet:
112             return
113         dirstr = not self.quiet and f'{self.style(direction, fg="white", bold=True)} ' or ''
114         self.echo(f'{dirstr} {title}')
115         if body and show_body:
116             self.echo(body)
117 
118 
119 def handle_preload_options(f):
120     """Extract preload options and return a wrapped callable."""
121     def caller(ctx, *args, **kwargs):
122         app = ctx.obj.app
123 
124         preload_options = [o.name for o in app.user_options.get('preload', [])]
125 
126         if preload_options:
127             user_options = {
128                 preload_option: kwargs[preload_option]
129                 for preload_option in preload_options
130             }
131 
132             user_preload_options.send(sender=f, app=app, options=user_options)
133 
134         return f(ctx, *args, **kwargs)
135 
136     return update_wrapper(caller, f)
137 
138 
139 class CeleryOption(click.Option):
140     """Customized option for Celery."""
141 
142     def get_default(self, ctx, *args, **kwargs):
143         if self.default_value_from_context:
144             self.default = ctx.obj[self.default_value_from_context]
145         return super().get_default(ctx, *args, **kwargs)
146 
147     def __init__(self, *args, **kwargs):
148         """Initialize a Celery option."""
149         self.help_group = kwargs.pop('help_group', None)
150         self.default_value_from_context = kwargs.pop('default_value_from_context', None)
151         super().__init__(*args, **kwargs)
152 
153 
154 class CeleryCommand(click.Command):
155     """Customized command for Celery."""
156 
157     def format_options(self, ctx, formatter):
158         """Write all the options into the formatter if they exist."""
159         opts = OrderedDict()
160         for param in self.get_params(ctx):
161             rv = param.get_help_record(ctx)
162             if rv is not None:
163                 if hasattr(param, 'help_group') and param.help_group:
164                     opts.setdefault(str(param.help_group), []).append(rv)
165                 else:
166                     opts.setdefault('Options', []).append(rv)
167 
168         for name, opts_group in opts.items():
169             with formatter.section(name):
170                 formatter.write_dl(opts_group)
171 
172 
173 class CeleryDaemonCommand(CeleryCommand):
174     """Daemon commands."""
175 
176     def __init__(self, *args, **kwargs):
177         """Initialize a Celery command with common daemon options."""
178         super().__init__(*args, **kwargs)
179         self.params.append(CeleryOption(('-f', '--logfile'), help_group="Daemonization Options"))
180         self.params.append(CeleryOption(('--pidfile',), help_group="Daemonization Options"))
181         self.params.append(CeleryOption(('--uid',), help_group="Daemonization Options"))
182         self.params.append(CeleryOption(('--uid',), help_group="Daemonization Options"))
183         self.params.append(CeleryOption(('--gid',), help_group="Daemonization Options"))
184         self.params.append(CeleryOption(('--umask',), help_group="Daemonization Options"))
185         self.params.append(CeleryOption(('--executable',), help_group="Daemonization Options"))
186 
187 
188 class CommaSeparatedList(ParamType):
189     """Comma separated list argument."""
190 
191     name = "comma separated list"
192 
193     def convert(self, value, param, ctx):
194         return text.str_to_list(value)
195 
196 
197 class JsonArray(ParamType):
198     """JSON formatted array argument."""
199 
200     name = "json array"
201 
202     def convert(self, value, param, ctx):
203         if isinstance(value, list):
204             return value
205 
206         try:
207             v = json.loads(value)
208         except ValueError as e:
209             self.fail(str(e))
210 
211         if not isinstance(v, list):
212             self.fail(f"{value} was not an array")
213 
214         return v
215 
216 
217 class JsonObject(ParamType):
218     """JSON formatted object argument."""
219 
220     name = "json object"
221 
222     def convert(self, value, param, ctx):
223         if isinstance(value, dict):
224             return value
225 
226         try:
227             v = json.loads(value)
228         except ValueError as e:
229             self.fail(str(e))
230 
231         if not isinstance(v, dict):
232             self.fail(f"{value} was not an object")
233 
234         return v
235 
236 
237 class ISO8601DateTime(ParamType):
238     """ISO 8601 Date Time argument."""
239 
240     name = "iso-86091"
241 
242     def convert(self, value, param, ctx):
243         try:
244             return maybe_iso8601(value)
245         except (TypeError, ValueError) as e:
246             self.fail(e)
247 
248 
249 class ISO8601DateTimeOrFloat(ParamType):
250     """ISO 8601 Date Time or float argument."""
251 
252     name = "iso-86091 or float"
253 
254     def convert(self, value, param, ctx):
255         try:
256             return float(value)
257         except (TypeError, ValueError):
258             pass
259 
260         try:
261             return maybe_iso8601(value)
262         except (TypeError, ValueError) as e:
263             self.fail(e)
264 
265 
266 class LogLevel(click.Choice):
267     """Log level option."""
268 
269     def __init__(self):
270         """Initialize the log level option with the relevant choices."""
271         super().__init__(('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL', 'FATAL'))
272 
273     def convert(self, value, param, ctx):
274         if isinstance(value, numbers.Integral):
275             return value
276 
277         value = value.upper()
278         value = super().convert(value, param, ctx)
279         return mlevel(value)
280 
281 
282 JSON_ARRAY = JsonArray()
283 JSON_OBJECT = JsonObject()
284 ISO8601 = ISO8601DateTime()
285 ISO8601_OR_FLOAT = ISO8601DateTimeOrFloat()
286 LOG_LEVEL = LogLevel()
287 COMMA_SEPARATED_LIST = CommaSeparatedList()
288
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/celery/bin/base.py b/celery/bin/base.py
--- a/celery/bin/base.py
+++ b/celery/bin/base.py
@@ -179,7 +179,6 @@
         self.params.append(CeleryOption(('-f', '--logfile'), help_group="Daemonization Options"))
         self.params.append(CeleryOption(('--pidfile',), help_group="Daemonization Options"))
         self.params.append(CeleryOption(('--uid',), help_group="Daemonization Options"))
-        self.params.append(CeleryOption(('--uid',), help_group="Daemonization Options"))
         self.params.append(CeleryOption(('--gid',), help_group="Daemonization Options"))
         self.params.append(CeleryOption(('--umask',), help_group="Daemonization Options"))
         self.params.append(CeleryOption(('--executable',), help_group="Daemonization Options"))

{"golden_diff": "diff --git a/celery/bin/base.py b/celery/bin/base.py\n--- a/celery/bin/base.py\n+++ b/celery/bin/base.py\n@@ -179,7 +179,6 @@\n         self.params.append(CeleryOption(('-f', '--logfile'), help_group=\"Daemonization Options\"))\n         self.params.append(CeleryOption(('--pidfile',), help_group=\"Daemonization Options\"))\n         self.params.append(CeleryOption(('--uid',), help_group=\"Daemonization Options\"))\n-        self.params.append(CeleryOption(('--uid',), help_group=\"Daemonization Options\"))\n         self.params.append(CeleryOption(('--gid',), help_group=\"Daemonization Options\"))\n         self.params.append(CeleryOption(('--umask',), help_group=\"Daemonization Options\"))\n         self.params.append(CeleryOption(('--executable',), help_group=\"Daemonization Options\"))\n", "issue": "Duplicate param 'uid' in CeleryDaemonCommand\n\r\n# Checklist\r\n\r\n- [ 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+)\r\n  for similar or identical bug reports.\r\n- [x ] I have checked the [pull requests list](https://github.com/celery/celery/pulls?q=is%3Apr+label%3A%22Category%3A+Documentation%22)\r\n  for existing proposed fixes.\r\n- [ x] I have checked the [commit log](https://github.com/celery/celery/commits/master)\r\n  to find out if the bug was already fixed in the master branch.\r\n- [ x] I have included all related issues and possible duplicate issues in this issue\r\n      (If there are none, check this box anyway).\r\n\r\n## Related Issues and Possible Duplicates\r\n\r\n#### Related Issues\r\n\r\n- None\r\n\r\n#### Possible Duplicates\r\n\r\n- None\r\n\r\n# Description\r\n\r\nCeleryDaemonCommand have duplicated CeleryOption for --uid which leads to all docs using it to have duplicated line (beat, multi, worker, etc).\r\n\r\n# Suggestions\r\n\r\nRemove the duplicate in CeleryDaemonCommand in celery/celery/bin/base.py \r\n\n", "before_files": [{"content": "\"\"\"Click customizations for Celery.\"\"\"\nimport json\nimport numbers\nfrom collections import OrderedDict\nfrom functools import update_wrapper\nfrom pprint import pformat\n\nimport click\nfrom click import ParamType\nfrom kombu.utils.objects import cached_property\n\nfrom celery._state import get_current_app\nfrom celery.signals import user_preload_options\nfrom celery.utils import text\nfrom celery.utils.log import mlevel\nfrom celery.utils.time import maybe_iso8601\n\ntry:\n    from pygments import highlight\n    from pygments.formatters import Terminal256Formatter\n    from pygments.lexers import PythonLexer\nexcept ImportError:\n    def highlight(s, *args, **kwargs):\n        \"\"\"Place holder function in case pygments is missing.\"\"\"\n        return s\n    LEXER = None\n    FORMATTER = None\nelse:\n    LEXER = PythonLexer()\n    FORMATTER = Terminal256Formatter()\n\n\nclass CLIContext:\n    \"\"\"Context Object for the CLI.\"\"\"\n\n    def __init__(self, app, no_color, workdir, quiet=False):\n        \"\"\"Initialize the CLI context.\"\"\"\n        self.app = app or get_current_app()\n        self.no_color = no_color\n        self.quiet = quiet\n        self.workdir = workdir\n\n    @cached_property\n    def OK(self):\n        return self.style(\"OK\", fg=\"green\", bold=True)\n\n    @cached_property\n    def ERROR(self):\n        return self.style(\"ERROR\", fg=\"red\", bold=True)\n\n    def style(self, message=None, **kwargs):\n        if self.no_color:\n            return message\n        else:\n            return click.style(message, **kwargs)\n\n    def secho(self, message=None, **kwargs):\n        if self.no_color:\n            kwargs['color'] = False\n            click.echo(message, **kwargs)\n        else:\n            click.secho(message, **kwargs)\n\n    def echo(self, message=None, **kwargs):\n        if self.no_color:\n            kwargs['color'] = False\n            click.echo(message, **kwargs)\n        else:\n            click.echo(message, **kwargs)\n\n    def error(self, message=None, **kwargs):\n        kwargs['err'] = True\n        if self.no_color:\n            kwargs['color'] = False\n            click.echo(message, **kwargs)\n        else:\n            click.secho(message, **kwargs)\n\n    def pretty(self, n):\n        if isinstance(n, list):\n            return self.OK, self.pretty_list(n)\n        if isinstance(n, dict):\n            if 'ok' in n or 'error' in n:\n                return self.pretty_dict_ok_error(n)\n            else:\n                s = json.dumps(n, sort_keys=True, indent=4)\n                if not self.no_color:\n                    s = highlight(s, LEXER, FORMATTER)\n                return self.OK, s\n        if isinstance(n, str):\n            return self.OK, n\n        return self.OK, pformat(n)\n\n    def pretty_list(self, n):\n        if not n:\n            return '- empty -'\n        return '\\n'.join(\n            f'{self.style(\"*\", fg=\"white\")} {item}' for item in n\n        )\n\n    def pretty_dict_ok_error(self, n):\n        try:\n            return (self.OK,\n                    text.indent(self.pretty(n['ok'])[1], 4))\n        except KeyError:\n            pass\n        return (self.ERROR,\n                text.indent(self.pretty(n['error'])[1], 4))\n\n    def say_chat(self, direction, title, body='', show_body=False):\n        if direction == '<-' and self.quiet:\n            return\n        dirstr = not self.quiet and f'{self.style(direction, fg=\"white\", bold=True)} ' or ''\n        self.echo(f'{dirstr} {title}')\n        if body and show_body:\n            self.echo(body)\n\n\ndef handle_preload_options(f):\n    \"\"\"Extract preload options and return a wrapped callable.\"\"\"\n    def caller(ctx, *args, **kwargs):\n        app = ctx.obj.app\n\n        preload_options = [o.name for o in app.user_options.get('preload', [])]\n\n        if preload_options:\n            user_options = {\n                preload_option: kwargs[preload_option]\n                for preload_option in preload_options\n            }\n\n            user_preload_options.send(sender=f, app=app, options=user_options)\n\n        return f(ctx, *args, **kwargs)\n\n    return update_wrapper(caller, f)\n\n\nclass CeleryOption(click.Option):\n    \"\"\"Customized option for Celery.\"\"\"\n\n    def get_default(self, ctx, *args, **kwargs):\n        if self.default_value_from_context:\n            self.default = ctx.obj[self.default_value_from_context]\n        return super().get_default(ctx, *args, **kwargs)\n\n    def __init__(self, *args, **kwargs):\n        \"\"\"Initialize a Celery option.\"\"\"\n        self.help_group = kwargs.pop('help_group', None)\n        self.default_value_from_context = kwargs.pop('default_value_from_context', None)\n        super().__init__(*args, **kwargs)\n\n\nclass CeleryCommand(click.Command):\n    \"\"\"Customized command for Celery.\"\"\"\n\n    def format_options(self, ctx, formatter):\n        \"\"\"Write all the options into the formatter if they exist.\"\"\"\n        opts = OrderedDict()\n        for param in self.get_params(ctx):\n            rv = param.get_help_record(ctx)\n            if rv is not None:\n                if hasattr(param, 'help_group') and param.help_group:\n                    opts.setdefault(str(param.help_group), []).append(rv)\n                else:\n                    opts.setdefault('Options', []).append(rv)\n\n        for name, opts_group in opts.items():\n            with formatter.section(name):\n                formatter.write_dl(opts_group)\n\n\nclass CeleryDaemonCommand(CeleryCommand):\n    \"\"\"Daemon commands.\"\"\"\n\n    def __init__(self, *args, **kwargs):\n        \"\"\"Initialize a Celery command with common daemon options.\"\"\"\n        super().__init__(*args, **kwargs)\n        self.params.append(CeleryOption(('-f', '--logfile'), help_group=\"Daemonization Options\"))\n        self.params.append(CeleryOption(('--pidfile',), help_group=\"Daemonization Options\"))\n        self.params.append(CeleryOption(('--uid',), help_group=\"Daemonization Options\"))\n        self.params.append(CeleryOption(('--uid',), help_group=\"Daemonization Options\"))\n        self.params.append(CeleryOption(('--gid',), help_group=\"Daemonization Options\"))\n        self.params.append(CeleryOption(('--umask',), help_group=\"Daemonization Options\"))\n        self.params.append(CeleryOption(('--executable',), help_group=\"Daemonization Options\"))\n\n\nclass CommaSeparatedList(ParamType):\n    \"\"\"Comma separated list argument.\"\"\"\n\n    name = \"comma separated list\"\n\n    def convert(self, value, param, ctx):\n        return text.str_to_list(value)\n\n\nclass JsonArray(ParamType):\n    \"\"\"JSON formatted array argument.\"\"\"\n\n    name = \"json array\"\n\n    def convert(self, value, param, ctx):\n        if isinstance(value, list):\n            return value\n\n        try:\n            v = json.loads(value)\n        except ValueError as e:\n            self.fail(str(e))\n\n        if not isinstance(v, list):\n            self.fail(f\"{value} was not an array\")\n\n        return v\n\n\nclass JsonObject(ParamType):\n    \"\"\"JSON formatted object argument.\"\"\"\n\n    name = \"json object\"\n\n    def convert(self, value, param, ctx):\n        if isinstance(value, dict):\n            return value\n\n        try:\n            v = json.loads(value)\n        except ValueError as e:\n            self.fail(str(e))\n\n        if not isinstance(v, dict):\n            self.fail(f\"{value} was not an object\")\n\n        return v\n\n\nclass ISO8601DateTime(ParamType):\n    \"\"\"ISO 8601 Date Time argument.\"\"\"\n\n    name = \"iso-86091\"\n\n    def convert(self, value, param, ctx):\n        try:\n            return maybe_iso8601(value)\n        except (TypeError, ValueError) as e:\n            self.fail(e)\n\n\nclass ISO8601DateTimeOrFloat(ParamType):\n    \"\"\"ISO 8601 Date Time or float argument.\"\"\"\n\n    name = \"iso-86091 or float\"\n\n    def convert(self, value, param, ctx):\n        try:\n            return float(value)\n        except (TypeError, ValueError):\n            pass\n\n        try:\n            return maybe_iso8601(value)\n        except (TypeError, ValueError) as e:\n            self.fail(e)\n\n\nclass LogLevel(click.Choice):\n    \"\"\"Log level option.\"\"\"\n\n    def __init__(self):\n        \"\"\"Initialize the log level option with the relevant choices.\"\"\"\n        super().__init__(('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL', 'FATAL'))\n\n    def convert(self, value, param, ctx):\n        if isinstance(value, numbers.Integral):\n            return value\n\n        value = value.upper()\n        value = super().convert(value, param, ctx)\n        return mlevel(value)\n\n\nJSON_ARRAY = JsonArray()\nJSON_OBJECT = JsonObject()\nISO8601 = ISO8601DateTime()\nISO8601_OR_FLOAT = ISO8601DateTimeOrFloat()\nLOG_LEVEL = LogLevel()\nCOMMA_SEPARATED_LIST = CommaSeparatedList()\n", "path": "celery/bin/base.py"}], "after_files": [{"content": "\"\"\"Click customizations for Celery.\"\"\"\nimport json\nimport numbers\nfrom collections import OrderedDict\nfrom functools import update_wrapper\nfrom pprint import pformat\n\nimport click\nfrom click import ParamType\nfrom kombu.utils.objects import cached_property\n\nfrom celery._state import get_current_app\nfrom celery.signals import user_preload_options\nfrom celery.utils import text\nfrom celery.utils.log import mlevel\nfrom celery.utils.time import maybe_iso8601\n\ntry:\n    from pygments import highlight\n    from pygments.formatters import Terminal256Formatter\n    from pygments.lexers import PythonLexer\nexcept ImportError:\n    def highlight(s, *args, **kwargs):\n        \"\"\"Place holder function in case pygments is missing.\"\"\"\n        return s\n    LEXER = None\n    FORMATTER = None\nelse:\n    LEXER = PythonLexer()\n    FORMATTER = Terminal256Formatter()\n\n\nclass CLIContext:\n    \"\"\"Context Object for the CLI.\"\"\"\n\n    def __init__(self, app, no_color, workdir, quiet=False):\n        \"\"\"Initialize the CLI context.\"\"\"\n        self.app = app or get_current_app()\n        self.no_color = no_color\n        self.quiet = quiet\n        self.workdir = workdir\n\n    @cached_property\n    def OK(self):\n        return self.style(\"OK\", fg=\"green\", bold=True)\n\n    @cached_property\n    def ERROR(self):\n        return self.style(\"ERROR\", fg=\"red\", bold=True)\n\n    def style(self, message=None, **kwargs):\n        if self.no_color:\n            return message\n        else:\n            return click.style(message, **kwargs)\n\n    def secho(self, message=None, **kwargs):\n        if self.no_color:\n            kwargs['color'] = False\n            click.echo(message, **kwargs)\n        else:\n            click.secho(message, **kwargs)\n\n    def echo(self, message=None, **kwargs):\n        if self.no_color:\n            kwargs['color'] = False\n            click.echo(message, **kwargs)\n        else:\n            click.echo(message, **kwargs)\n\n    def error(self, message=None, **kwargs):\n        kwargs['err'] = True\n        if self.no_color:\n            kwargs['color'] = False\n            click.echo(message, **kwargs)\n        else:\n            click.secho(message, **kwargs)\n\n    def pretty(self, n):\n        if isinstance(n, list):\n            return self.OK, self.pretty_list(n)\n        if isinstance(n, dict):\n            if 'ok' in n or 'error' in n:\n                return self.pretty_dict_ok_error(n)\n            else:\n                s = json.dumps(n, sort_keys=True, indent=4)\n                if not self.no_color:\n                    s = highlight(s, LEXER, FORMATTER)\n                return self.OK, s\n        if isinstance(n, str):\n            return self.OK, n\n        return self.OK, pformat(n)\n\n    def pretty_list(self, n):\n        if not n:\n            return '- empty -'\n        return '\\n'.join(\n            f'{self.style(\"*\", fg=\"white\")} {item}' for item in n\n        )\n\n    def pretty_dict_ok_error(self, n):\n        try:\n            return (self.OK,\n                    text.indent(self.pretty(n['ok'])[1], 4))\n        except KeyError:\n            pass\n        return (self.ERROR,\n                text.indent(self.pretty(n['error'])[1], 4))\n\n    def say_chat(self, direction, title, body='', show_body=False):\n        if direction == '<-' and self.quiet:\n            return\n        dirstr = not self.quiet and f'{self.style(direction, fg=\"white\", bold=True)} ' or ''\n        self.echo(f'{dirstr} {title}')\n        if body and show_body:\n            self.echo(body)\n\n\ndef handle_preload_options(f):\n    \"\"\"Extract preload options and return a wrapped callable.\"\"\"\n    def caller(ctx, *args, **kwargs):\n        app = ctx.obj.app\n\n        preload_options = [o.name for o in app.user_options.get('preload', [])]\n\n        if preload_options:\n            user_options = {\n                preload_option: kwargs[preload_option]\n                for preload_option in preload_options\n            }\n\n            user_preload_options.send(sender=f, app=app, options=user_options)\n\n        return f(ctx, *args, **kwargs)\n\n    return update_wrapper(caller, f)\n\n\nclass CeleryOption(click.Option):\n    \"\"\"Customized option for Celery.\"\"\"\n\n    def get_default(self, ctx, *args, **kwargs):\n        if self.default_value_from_context:\n            self.default = ctx.obj[self.default_value_from_context]\n        return super().get_default(ctx, *args, **kwargs)\n\n    def __init__(self, *args, **kwargs):\n        \"\"\"Initialize a Celery option.\"\"\"\n        self.help_group = kwargs.pop('help_group', None)\n        self.default_value_from_context = kwargs.pop('default_value_from_context', None)\n        super().__init__(*args, **kwargs)\n\n\nclass CeleryCommand(click.Command):\n    \"\"\"Customized command for Celery.\"\"\"\n\n    def format_options(self, ctx, formatter):\n        \"\"\"Write all the options into the formatter if they exist.\"\"\"\n        opts = OrderedDict()\n        for param in self.get_params(ctx):\n            rv = param.get_help_record(ctx)\n            if rv is not None:\n                if hasattr(param, 'help_group') and param.help_group:\n                    opts.setdefault(str(param.help_group), []).append(rv)\n                else:\n                    opts.setdefault('Options', []).append(rv)\n\n        for name, opts_group in opts.items():\n            with formatter.section(name):\n                formatter.write_dl(opts_group)\n\n\nclass CeleryDaemonCommand(CeleryCommand):\n    \"\"\"Daemon commands.\"\"\"\n\n    def __init__(self, *args, **kwargs):\n        \"\"\"Initialize a Celery command with common daemon options.\"\"\"\n        super().__init__(*args, **kwargs)\n        self.params.append(CeleryOption(('-f', '--logfile'), help_group=\"Daemonization Options\"))\n        self.params.append(CeleryOption(('--pidfile',), help_group=\"Daemonization Options\"))\n        self.params.append(CeleryOption(('--uid',), help_group=\"Daemonization Options\"))\n        self.params.append(CeleryOption(('--gid',), help_group=\"Daemonization Options\"))\n        self.params.append(CeleryOption(('--umask',), help_group=\"Daemonization Options\"))\n        self.params.append(CeleryOption(('--executable',), help_group=\"Daemonization Options\"))\n\n\nclass CommaSeparatedList(ParamType):\n    \"\"\"Comma separated list argument.\"\"\"\n\n    name = \"comma separated list\"\n\n    def convert(self, value, param, ctx):\n        return text.str_to_list(value)\n\n\nclass JsonArray(ParamType):\n    \"\"\"JSON formatted array argument.\"\"\"\n\n    name = \"json array\"\n\n    def convert(self, value, param, ctx):\n        if isinstance(value, list):\n            return value\n\n        try:\n            v = json.loads(value)\n        except ValueError as e:\n            self.fail(str(e))\n\n        if not isinstance(v, list):\n            self.fail(f\"{value} was not an array\")\n\n        return v\n\n\nclass JsonObject(ParamType):\n    \"\"\"JSON formatted object argument.\"\"\"\n\n    name = \"json object\"\n\n    def convert(self, value, param, ctx):\n        if isinstance(value, dict):\n            return value\n\n        try:\n            v = json.loads(value)\n        except ValueError as e:\n            self.fail(str(e))\n\n        if not isinstance(v, dict):\n            self.fail(f\"{value} was not an object\")\n\n        return v\n\n\nclass ISO8601DateTime(ParamType):\n    \"\"\"ISO 8601 Date Time argument.\"\"\"\n\n    name = \"iso-86091\"\n\n    def convert(self, value, param, ctx):\n        try:\n            return maybe_iso8601(value)\n        except (TypeError, ValueError) as e:\n            self.fail(e)\n\n\nclass ISO8601DateTimeOrFloat(ParamType):\n    \"\"\"ISO 8601 Date Time or float argument.\"\"\"\n\n    name = \"iso-86091 or float\"\n\n    def convert(self, value, param, ctx):\n        try:\n            return float(value)\n        except (TypeError, ValueError):\n            pass\n\n        try:\n            return maybe_iso8601(value)\n        except (TypeError, ValueError) as e:\n            self.fail(e)\n\n\nclass LogLevel(click.Choice):\n    \"\"\"Log level option.\"\"\"\n\n    def __init__(self):\n        \"\"\"Initialize the log level option with the relevant choices.\"\"\"\n        super().__init__(('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL', 'FATAL'))\n\n    def convert(self, value, param, ctx):\n        if isinstance(value, numbers.Integral):\n            return value\n\n        value = value.upper()\n        value = super().convert(value, param, ctx)\n        return mlevel(value)\n\n\nJSON_ARRAY = JsonArray()\nJSON_OBJECT = JsonObject()\nISO8601 = ISO8601DateTime()\nISO8601_OR_FLOAT = ISO8601DateTimeOrFloat()\nLOG_LEVEL = LogLevel()\nCOMMA_SEPARATED_LIST = CommaSeparatedList()\n", "path": "celery/bin/base.py"}]}