Return the --db path or raise a UsageError if not set. When *must_exist* is True, also verify the file is present on disk.
(ctx: click.Context, *, must_exist: bool = False)
| 500 | |
| 501 | |
| 502 | def _require_db(ctx: click.Context, *, must_exist: bool = False) -> str: |
| 503 | """Return the --db path or raise a UsageError if not set. |
| 504 | |
| 505 | When *must_exist* is True, also verify the file is present on disk. |
| 506 | """ |
| 507 | db = ctx.obj["db"] |
| 508 | if not db: |
| 509 | raise click.UsageError("No database path. Set DB_PATH or pass --db.") |
| 510 | if must_exist and not os.path.isfile(db): |
| 511 | raise click.UsageError(f"Database not found: {db}") |
| 512 | return db |
| 513 | |
| 514 | |
| 515 | @cli.command() |
no outgoing calls
no test coverage detected