Skip to content

Commit 6d88942

Browse files
authored
Tui separation and simplification (#65)
* Move tui dependencies to be optional * Identify processed files both with suffix and prefix --------- Co-authored-by: avvertix <5672748+avvertix@users.noreply.github.com>
1 parent 11a405b commit 6d88942

16 files changed

Lines changed: 984 additions & 851 deletions

File tree

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ dependencies = [
2121
"opentelemetry-exporter-otlp>=1.37.0",
2222
"opentelemetry-proto>=1.37.0",
2323
"opentelemetry-sdk>=1.37.0",
24-
"textual>=0.89.0",
2524
]
2625

2726
[project.scripts]
@@ -40,16 +39,18 @@ llmwhisperer = [
4039
unstructured_local = [
4140
"unstructured[pdf]>=0.18.13",
4241
]
43-
4442
landingai = [
45-
"landingai-ade>=0.15.1"
43+
"landingai-ade>=0.15.1",
44+
]
45+
tui = [
46+
"textual>=0.89.0",
4647
]
47-
4848
all = [
4949
"llama-cloud-services>=0.6.77",
5050
"llmwhisperer-client>=2.4.2",
5151
"unstructured[pdf]>=0.18.13",
5252
"landingai-ade>=0.15.1",
53+
"textual>=0.89.0",
5354
]
5455

5556

src/parxy_cli/commands/tui.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
"""Command to launch the Parxy TUI."""
22

33
from pathlib import Path
4-
from typing import Annotated
4+
from typing import Annotated, Optional
55

66
import typer
77

88
from parxy_cli.console.console import Console
9-
from parxy_cli.tui.app import run_tui
109

1110
app = typer.Typer(
1211
name='tui', help='Launch the Parxy TUI for interactive parser comparison'
@@ -18,40 +17,60 @@
1817
@app.callback(invoke_without_command=True)
1918
def tui(
2019
workspace: Annotated[
21-
str,
20+
Optional[str],
2221
typer.Argument(
23-
help='Path to the workspace folder containing documents to process',
22+
help='Path to the workspace folder (optional — can be selected inside the TUI)',
2423
),
25-
],
24+
] = None,
2625
):
2726
"""
2827
Launch the Parxy TUI for interactive parser comparison.
2928
29+
If no workspace is provided, the TUI opens a folder selection screen.
30+
3031
The TUI provides an interactive interface to:
3132
- Browse files in your workspace
3233
- Select multiple parsers to compare
3334
- View parsing results side-by-side
3435
- See JSON and Markdown diffs between parsers
3536
37+
Requires the tui extra: pip install 'parxy[tui]'
38+
3639
Examples:
3740
41+
# Launch TUI and select a folder interactively
42+
parxy tui
43+
3844
# Launch TUI with current directory
3945
parxy tui .
4046
4147
# Launch TUI with specific folder
4248
parxy tui /path/to/documents
4349
"""
44-
workspace_path = Path(workspace).resolve()
50+
workspace_path: Optional[Path] = None
4551

46-
if not workspace_path.exists():
47-
console.error(f'Workspace path does not exist: {workspace_path}')
48-
raise typer.Exit(1)
52+
if workspace is not None:
53+
workspace_path = Path(workspace).resolve()
4954

50-
if not workspace_path.is_dir():
51-
console.error(f'Workspace path is not a directory: {workspace_path}')
55+
if not workspace_path.exists():
56+
console.error(f'Workspace path does not exist: {workspace_path}')
57+
raise typer.Exit(1)
58+
59+
if not workspace_path.is_dir():
60+
console.error(f'Workspace path is not a directory: {workspace_path}')
61+
raise typer.Exit(1)
62+
63+
try:
64+
from parxy_cli.tui.app import run_tui
65+
except ImportError:
66+
console.error(
67+
"The TUI requires the 'tui' extra. Install it with:\n\n"
68+
" pip install 'parxy[tui]'"
69+
)
5270
raise typer.Exit(1)
5371

54-
console.info(f'Starting Parxy TUI with workspace: {workspace_path}')
72+
if workspace_path:
73+
console.info(f'Starting Parxy TUI with workspace: {workspace_path}')
5574

5675
try:
5776
run_tui(workspace_path)

0 commit comments

Comments
 (0)