[PATCH 2 of 4] cli: fix celery-run usage text

Thomas De Schampheleire patrickdepinguin at gmail.com
Thu Nov 22 21:36:05 UTC 2018


# 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 367991450bc641655533763d6214f6db3d1b79cc
# Parent  c33600f1151b81dcafda40e3003d4899c9c4189a
cli: fix celery-run usage text

Make sure that the help text and error messages from Celery (e.g. by passing
'-- --help' or '-- -xyz') contain a valid 'Usage:' string.

Without these changes, the usage string is:
    Usage: kallithea celery worker /home/tdescham/repo/contrib/kallithea/venv/kallithea-release/bin/kallithea-cli [options]

With the changes, it becomes:
    Usage: kallithea-cli celery-run CONFIG_FILE -- [options]

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
@@ -16,6 +16,8 @@ import click
 import kallithea.bin.kallithea_cli_base as cli_base
 
 import kallithea
+import os
+import sys
 
 @cli_base.register_command(config_file_initialize_app=True)
 @click.argument('celery_args', nargs=-1)
@@ -36,4 +38,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(prog_name='%s celery-run' % os.path.basename(sys.argv[0]), argv=list(celery_args), command='CONFIG_FILE --')


More information about the kallithea-general mailing list