sqlitexplorer 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ """Shell-completion callbacks for Typer parameters."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+
7
+ import typer
8
+
9
+ from sqlitexplorer.core import ExplorerError, open_database
10
+
11
+
12
+ def complete_table(ctx: typer.Context, incomplete: str) -> list[str]:
13
+ """Complete a table or view name from the database given earlier on the command line."""
14
+ database = ctx.params.get("database")
15
+ if not database:
16
+ return []
17
+ try:
18
+ with open_database(Path(database)) as db:
19
+ names = db.names()
20
+ except (ExplorerError, OSError):
21
+ return []
22
+ return [name for name in names if name.startswith(incomplete)]