Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 41 additions & 35 deletions invenio_cli/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,6 @@ def init(flavour, template, checkout, user_input, config):
cookiecutter_wrapper.remove_config()


@invenio_cli.group("run", invoke_without_command=True)
@click.pass_context
def run_group(ctx):
"""Run command group."""
# For backward compatibility
if ctx.invoked_subcommand is None:
ctx.invoke(run_all)


services_option = click.option(
"--services/--no-services",
"-s/-n",
default=True,
is_flag=True,
help="Enable/disable dockerized services (default: enabled).",
)
web_options = combine_decorators(
click.option(
"--host",
Expand All @@ -188,25 +172,13 @@ def run_group(ctx):
)


@run_group.command("web")
@services_option
@web_options
@pass_cli_config
def run_web(cli_config, host, port, debug, services):
"""Starts the local development web server."""
if services:
cmds = ServicesCommands(cli_config)
response = cmds.ensure_containers_running()
# fail and exit if containers are not running
handle_process_response(response)

host = host or cli_config.get_web_host()
port = port or cli_config.get_web_port()

commands = LocalCommands(cli_config)
processes = commands.run_web(host=host, port=str(port), debug=debug)
for proc in processes:
proc.wait()
services_option = click.option(
"--services/--no-services",
"-s/-n",
default=True,
is_flag=True,
help="Enable/disable dockerized services (default: enabled).",
)


worker_options = combine_decorators(
Expand All @@ -228,6 +200,40 @@ def run_web(cli_config, host, port, debug, services):
)


@invenio_cli.group("run", invoke_without_command=True)
@web_options # this and below for backwards-compatibility
@services_option
@worker_options
@pass_cli_config
Comment on lines +204 to +207
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this and the forward() call below are the main points for the interface

@click.pass_context
def run_group(ctx, *args, **kwargs):
"""Run command group."""
# For backward compatibility
if ctx.invoked_subcommand is None:
ctx.forward(run_all)


@run_group.command("web")
@services_option
@web_options
@pass_cli_config
def run_web(cli_config, host, port, debug, services):
"""Starts the local development web server."""
if services:
cmds = ServicesCommands(cli_config)
response = cmds.ensure_containers_running()
# fail and exit if containers are not running
handle_process_response(response)

host = host or cli_config.get_web_host()
port = port or cli_config.get_web_port()

commands = LocalCommands(cli_config)
processes = commands.run_web(host=host, port=str(port), debug=debug)
for proc in processes:
proc.wait()


@run_group.command("worker")
@services_option
@worker_options
Expand Down
3 changes: 1 addition & 2 deletions invenio_cli/commands/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright (C) 2026 California Institute of Technology.
# Copyright (C) 2020 CERN.
# Copyright (C) 2022 Graz University of Technology.
# Copyright (C) 2026 Northwestern University.
#
# Invenio-Cli is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -165,8 +166,6 @@ def run_web(self, host, port, debug=True):
click.secho("Starting up local (development) server...", fg="green")
run_env = environ.copy()
run_env["FLASK_DEBUG"] = "1" if debug else "0"
run_env["INVENIO_SITE_UI_URL"] = f"https://{host}:{port}"
run_env["INVENIO_SITE_API_URL"] = f"https://{host}:{port}/api"
pkg_man = self.cli_config.python_package_manager
proc = popen(
pkg_man.run_command(
Expand Down