Skip to content

Commit 826a9e6

Browse files
feat: CLI implementation of change capture and live updates
1 parent 1d125c2 commit 826a9e6

File tree

4 files changed

+217
-232
lines changed

4 files changed

+217
-232
lines changed

python/cocoindex/cli.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ def ls(app_target: str | None) -> None:
186186
"--color/--no-color", default=True, help="Enable or disable colored output."
187187
)
188188
@click.option("--verbose", is_flag=True, help="Show verbose output with full details.")
189-
def show(app_flow_specifier: str, color: bool, verbose: bool) -> None:
189+
@click.option("--live-status", is_flag=True, help="Show live update status for each data source.")
190+
def show(app_flow_specifier: str, color: bool, verbose: bool, live_status: bool) -> None:
190191
"""
191192
Show the flow spec and schema.
192193
@@ -208,6 +209,15 @@ def show(app_flow_specifier: str, color: bool, verbose: bool) -> None:
208209
console = Console(no_color=not color)
209210
console.print(fl._render_spec(verbose=verbose))
210211
console.print()
212+
213+
if live_status:
214+
# Show live update status
215+
console.print("\n[bold cyan]Live Update Status:[/bold cyan]")
216+
options = flow.FlowLiveUpdaterOptions(live_mode=False, reexport_targets=False, print_stats=False)
217+
with flow.FlowLiveUpdater(fl, options) as updater:
218+
updater.print_cli_status()
219+
console.print()
220+
211221
table = Table(
212222
title=f"Schema for Flow: {fl.name}",
213223
title_style="cyan",
@@ -467,6 +477,10 @@ def update(
467477
else:
468478
assert len(flow_list) == 1
469479
with flow.FlowLiveUpdater(flow_list[0], options) as updater:
480+
if options.live_mode:
481+
# Show initial status
482+
updater.print_cli_status()
483+
click.echo()
470484
updater.wait()
471485
if options.live_mode:
472486
_show_no_live_update_hint()

python/cocoindex/flow.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,30 @@ def update_stats(self) -> _engine.IndexUpdateInfo:
678678
"""
679679
return self._get_engine_live_updater().index_update_info()
680680

681+
def print_cli_status(self) -> None:
682+
"""
683+
Print CLI status showing interval and change capture information for each source.
684+
"""
685+
execution_context.run(self.print_cli_status_async())
686+
687+
async def print_cli_status_async(self) -> None:
688+
"""
689+
Print CLI status showing interval and change capture information for each source. Async version.
690+
"""
691+
await self._get_engine_live_updater().print_cli_status_async()
692+
693+
def next_status_updates_cli(self) -> None:
694+
"""
695+
Get the next status updates and print CLI status.
696+
"""
697+
execution_context.run(self.next_status_updates_cli_async())
698+
699+
async def next_status_updates_cli_async(self) -> None:
700+
"""
701+
Get the next status updates and print CLI status. Async version.
702+
"""
703+
await self._get_engine_live_updater().next_status_updates_cli_async()
704+
681705
def _get_engine_live_updater(self) -> _engine.FlowLiveUpdater:
682706
if self._engine_live_updater is None:
683707
raise RuntimeError("Live updater is not started")

0 commit comments

Comments
 (0)