Skip to content

Commit 464dcce

Browse files
authored
feat(cli): add force option to setup and drop commands for bypassing confirmation prompts (#602)
1 parent 5c41c3e commit 464dcce

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

python/cocoindex/cli.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,15 @@ def show(app_flow_specifier: str, color: bool, verbose: bool) -> None:
237237

238238
@cli.command()
239239
@click.argument("app_target", type=str)
240-
def setup(app_target: str) -> None:
240+
@click.option(
241+
"-f",
242+
"--force",
243+
is_flag=True,
244+
show_default=True,
245+
default=False,
246+
help="Force setup without confirmation prompts.",
247+
)
248+
def setup(app_target: str, force: bool) -> None:
241249
"""
242250
Check and apply backend setup changes for flows, including the internal and target storage
243251
(to export).
@@ -252,7 +260,7 @@ def setup(app_target: str) -> None:
252260
if setup_status.is_up_to_date():
253261
click.echo("No changes need to be pushed.")
254262
return
255-
if not click.confirm(
263+
if not force and not click.confirm(
256264
"Changes need to be pushed. Continue? [yes/N]",
257265
default=False,
258266
show_default=False,
@@ -275,7 +283,17 @@ def setup(app_target: str) -> None:
275283
"even if not defined in the current process."
276284
"If used, APP_TARGET and any listed flow names are ignored.",
277285
)
278-
def drop(app_target: str | None, flow_name: tuple[str, ...], drop_all: bool) -> None:
286+
@click.option(
287+
"-f",
288+
"--force",
289+
is_flag=True,
290+
show_default=True,
291+
default=False,
292+
help="Force drop without confirmation prompts.",
293+
)
294+
def drop(
295+
app_target: str | None, flow_name: tuple[str, ...], drop_all: bool, force: bool
296+
) -> None:
279297
"""
280298
Drop the backend setup for flows.
281299
@@ -328,7 +346,7 @@ def drop(app_target: str | None, flow_name: tuple[str, ...], drop_all: bool) ->
328346
if setup_status.is_up_to_date():
329347
click.echo("No flows need to be dropped.")
330348
return
331-
if not click.confirm(
349+
if not force and not click.confirm(
332350
f"\nThis will apply changes to drop setup for: {', '.join(flow_names)}. Continue? [yes/N]",
333351
default=False,
334352
show_default=False,

0 commit comments

Comments
 (0)