From 7e7a1edec475d250e45c0f88f9d8c7fe3e5f6c55 Mon Sep 17 00:00:00 2001 From: GooglyBlox <53668973+GooglyBlox@users.noreply.github.com> Date: Wed, 22 Oct 2025 00:49:21 -0700 Subject: [PATCH] feat: deprecate setup flag --- docs/docs/core/cli-commands.md | 4 ++-- python/cocoindex/cli.py | 27 +++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/docs/docs/core/cli-commands.md b/docs/docs/core/cli-commands.md index 95011b46..7106c88b 100644 --- a/docs/docs/core/cli-commands.md +++ b/docs/docs/core/cli-commands.md @@ -108,7 +108,7 @@ cocoindex server [OPTIONS] APP_TARGET | `-ci, --cors-cocoindex` | Allow `https://cocoindex.io` to access the server. | | `-cl, --cors-local INTEGER` | Allow `http://localhost:` to access the server. | | `-L, --live-update` | Continuously watch changes from data sources and apply to the target index. | -| `--setup` | Automatically setup backends for the flow if it's not setup yet. | +| `--setup` | (DEPRECATED) Automatically setup backends for the flow if it's not setup yet. This is now the default behavior. [default: True] | | `--reset` | Drop existing setup before starting server (equivalent to running 'cocoindex drop' first). `--reset` implies `--setup`. | | `--reexport` | Reexport to targets even if there's no change. | | `-f, --force` | Force setup without confirmation prompts. | @@ -194,7 +194,7 @@ cocoindex update [OPTIONS] APP_FLOW_SPECIFIER |--------|-------------| | `-L, --live` | Continuously watch changes from data sources and apply to the target index. | | `--reexport` | Reexport to targets even if there's no change. | -| `--setup` | Automatically setup backends for the flow if it's not setup yet. | +| `--setup` | (DEPRECATED) Automatically setup backends for the flow if it's not setup yet. This is now the default behavior. [default: True] | | `--reset` | Drop existing setup before updating (equivalent to running 'cocoindex drop' first). `--reset` implies `--setup`. | | `-f, --force` | Force setup without confirmation prompts. | | `-q, --quiet` | Avoid printing anything to the standard output, e.g. statistics. | diff --git a/python/cocoindex/cli.py b/python/cocoindex/cli.py index 45a6b9ea..2451b0ea 100644 --- a/python/cocoindex/cli.py +++ b/python/cocoindex/cli.py @@ -251,6 +251,23 @@ def _drop_flows(flows: Iterable[flow.Flow], app_ref: str, force: bool = False) - setup_bundle.apply(report_to_stdout=True) +def _deprecate_setup_flag( + ctx: click.Context, param: click.Parameter, value: bool +) -> bool: + """Callback to warn users that --setup flag is deprecated.""" + # Check if the parameter was explicitly provided by the user + if param.name is not None: + param_source = ctx.get_parameter_source(param.name) + if param_source == click.core.ParameterSource.COMMANDLINE: + click.secho( + "Warning: The --setup flag is deprecated and will be removed in a future version. " + "Setup is now always enabled by default.", + fg="yellow", + err=True, + ) + return value + + def _setup_flows( flow_iter: Iterable[flow.Flow], *, @@ -392,8 +409,9 @@ def drop(app_target: str | None, flow_name: tuple[str, ...], force: bool) -> Non "--setup", is_flag=True, show_default=True, - default=False, - help="Automatically setup backends for the flow if it's not setup yet.", + default=True, + callback=_deprecate_setup_flag, + help="(DEPRECATED) Automatically setup backends for the flow if it's not setup yet. This is now the default behavior.", ) @click.option( "--reset", @@ -553,8 +571,9 @@ def evaluate( "--setup", is_flag=True, show_default=True, - default=False, - help="Automatically setup backends for the flow if it's not setup yet.", + default=True, + callback=_deprecate_setup_flag, + help="(DEPRECATED) Automatically setup backends for the flow if it's not setup yet. This is now the default behavior.", ) @click.option( "--reset",