From 17be770f9d55a9005b546e0f969af078fb359390 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Wed, 27 Apr 2022 12:05:15 +0200 Subject: make use of the 'help' parameter of click.command() decorator for localized help messages --- src/hydrilla/server/serve.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src/hydrilla') diff --git a/src/hydrilla/server/serve.py b/src/hydrilla/server/serve.py index d07d44f..a6a1204 100644 --- a/src/hydrilla/server/serve.py +++ b/src/hydrilla/server/serve.py @@ -572,6 +572,7 @@ default_project_url = 'https://hydrillabugs.koszko.org/projects/hydrilla/wiki' console_gettext = util.translation(here / 'locales').gettext _ = console_gettext +@click.command(help=_('serve_hydrilla_packages_explain_wsgi_considerations')) @click.option('-m', '--malcontent-dir', type=click.Path(exists=True, file_okay=False), help=_('directory_to_serve_from_overrides_config')) @@ -590,7 +591,12 @@ _ = console_gettext def start(malcontent_dir: Optional[str], hydrilla_project_url: Optional[str], port: Optional[int], config_path: Optional[str], language: Optional[str]) -> None: - """""" + """ + Run a development Hydrilla server. + + This command is meant to be the entry point of hydrilla command exported by + this package. + """ config_load_opts = {} if config_path is None \ else {'config_path': [Path(config_path)]} @@ -618,20 +624,19 @@ def start(malcontent_dir: Optional[str], hydrilla_project_url: Optional[str], HydrillaApp(hydrilla_config).run() -start.__doc__ = _('serve_hydrilla_packages_explain_wsgi_considerations') - -start = click.command()(start) - +@click.command(help=_('serve_hydrilla_packages_wsgi_help'), + context_settings={ + 'ignore_unknown_options': True, + 'allow_extra_args': True + }) @click.version_option(version=_version.version, prog_name='Hydrilla', message=_('%(prog)s_%(version)s_license'), help=_('version_printing')) def start_wsgi() -> None: - """""" - return HydrillaApp(click.get_current_context().obj or config.load()) - -start_wsgi.__doc__ = _('serve_hydrilla_packages_wsgi_help') + """ + Create application object for use in WSGI deployment. -start_wsgi = click.command(context_settings={ - 'ignore_unknown_options': True, - 'allow_extra_args': True -})(start_wsgi) + This command Also handles --help and --version options in case it gets + called outside WSGI environment. + """ + return HydrillaApp(click.get_current_context().obj or config.load()) -- cgit v1.2.3