[PATCH 2 of 4] cli: fix celery-run usage text
Mads Kiilerich
mads at kiilerich.com
Sun Nov 25 00:44:55 UTC 2018
For context, this is how it looks on stable branch, before the change to
gearbox "broke" it:
$ paster celeryd development.ini -h
Usage: paster celeryd [options] CONFIG_FILE [celeryd options...]
Also, looking more into it, it seems like the full_cmd_name proposed
previously is the same as click.get_current_context().command_path ?
But celery likes to get the executable name separate. The approach of
"hardcoding" the subcommand and options seems fine, but it seems like
'celery-run' is better as a part of the 'command', and we can let celery
/ optparse use the default prog_name.
So how about making this:
# HG changeset patch
# User Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>
# Date 1542922034 -3600
# Thu Nov 22 22:27:14 2018 +0100
# Node ID a4c3a76baa715e2d0371cfdec6df2a0d927e37f9
# Parent 2917d2be0106c5b26a280910b5e54bcad66bb747
cli: fix celery-run usage text
Make sure that the help text and error messages from Celery (e.g. from
'kallithea-cli celery-run -c my.ini -- --help' or '-- -xyz') contain a valid
'Usage:' string.
Without these changes, the usage string will use the arbitrary
description from
2c3d30095d5e and a full path:
Usage: kallithea celery worker .../bin/kallithea-cli [options]
With the changes, it becomes:
Usage: kallithea-cli celery-run -c CONFIG_FILE -- [options]
Click will let optparse find 'kallithea-cli' from argv[0]. The command part
'celery-run -c CONFIG_FILE --' could perhaps be found with Click
introspection,
but it is simpler and perhaps equally reliable to make it explicit.
diff --git a/kallithea/bin/kallithea_cli_celery.py
b/kallithea/bin/kallithea_cli_celery.py
--- a/kallithea/bin/kallithea_cli_celery.py
+++ b/kallithea/bin/kallithea_cli_celery.py
@@ -36,4 +36,4 @@ def celery_run(celery_args):
from kallithea.lib import celerypylons
cmd = celerypylons.worker.worker(celerypylons.app)
- return cmd.run_from_argv('kallithea celery worker', list(celery_args))
+ return cmd.run_from_argv(None, command='celery-run -c CONFIG_FILE
--', argv=list(celery_args))
More information about the kallithea-general
mailing list