Skip to content

Commit 4c6bb6e

Browse files
authored
feat: deprecate setup flag (#1212)
1 parent d44da9a commit 4c6bb6e

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

docs/docs/core/cli-commands.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ cocoindex server [OPTIONS] APP_TARGET
108108
| `-ci, --cors-cocoindex` | Allow `https://cocoindex.io` to access the server. |
109109
| `-cl, --cors-local INTEGER` | Allow `http://localhost:<port>` to access the server. |
110110
| `-L, --live-update` | Continuously watch changes from data sources and apply to the target index. |
111-
| `--setup` | Automatically setup backends for the flow if it's not setup yet. |
111+
| `--setup` | (DEPRECATED) Automatically setup backends for the flow if it's not setup yet. This is now the default behavior. [default: True] |
112112
| `--reset` | Drop existing setup before starting server (equivalent to running 'cocoindex drop' first). `--reset` implies `--setup`. |
113113
| `--reexport` | Reexport to targets even if there's no change. |
114114
| `-f, --force` | Force setup without confirmation prompts. |
@@ -194,7 +194,7 @@ cocoindex update [OPTIONS] APP_FLOW_SPECIFIER
194194
|--------|-------------|
195195
| `-L, --live` | Continuously watch changes from data sources and apply to the target index. |
196196
| `--reexport` | Reexport to targets even if there's no change. |
197-
| `--setup` | Automatically setup backends for the flow if it's not setup yet. |
197+
| `--setup` | (DEPRECATED) Automatically setup backends for the flow if it's not setup yet. This is now the default behavior. [default: True] |
198198
| `--reset` | Drop existing setup before updating (equivalent to running 'cocoindex drop' first). `--reset` implies `--setup`. |
199199
| `-f, --force` | Force setup without confirmation prompts. |
200200
| `-q, --quiet` | Avoid printing anything to the standard output, e.g. statistics. |

python/cocoindex/cli.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,23 @@ def _drop_flows(flows: Iterable[flow.Flow], app_ref: str, force: bool = False) -
251251
setup_bundle.apply(report_to_stdout=True)
252252

253253

254+
def _deprecate_setup_flag(
255+
ctx: click.Context, param: click.Parameter, value: bool
256+
) -> bool:
257+
"""Callback to warn users that --setup flag is deprecated."""
258+
# Check if the parameter was explicitly provided by the user
259+
if param.name is not None:
260+
param_source = ctx.get_parameter_source(param.name)
261+
if param_source == click.core.ParameterSource.COMMANDLINE:
262+
click.secho(
263+
"Warning: The --setup flag is deprecated and will be removed in a future version. "
264+
"Setup is now always enabled by default.",
265+
fg="yellow",
266+
err=True,
267+
)
268+
return value
269+
270+
254271
def _setup_flows(
255272
flow_iter: Iterable[flow.Flow],
256273
*,
@@ -392,8 +409,9 @@ def drop(app_target: str | None, flow_name: tuple[str, ...], force: bool) -> Non
392409
"--setup",
393410
is_flag=True,
394411
show_default=True,
395-
default=False,
396-
help="Automatically setup backends for the flow if it's not setup yet.",
412+
default=True,
413+
callback=_deprecate_setup_flag,
414+
help="(DEPRECATED) Automatically setup backends for the flow if it's not setup yet. This is now the default behavior.",
397415
)
398416
@click.option(
399417
"--reset",
@@ -553,8 +571,9 @@ def evaluate(
553571
"--setup",
554572
is_flag=True,
555573
show_default=True,
556-
default=False,
557-
help="Automatically setup backends for the flow if it's not setup yet.",
574+
default=True,
575+
callback=_deprecate_setup_flag,
576+
help="(DEPRECATED) Automatically setup backends for the flow if it's not setup yet. This is now the default behavior.",
558577
)
559578
@click.option(
560579
"--reset",

0 commit comments

Comments
 (0)