Add sub-projects
This commit is contained in:
24
packages/sshecret-backend/src/sshecret_backend/cli.py
Normal file
24
packages/sshecret-backend/src/sshecret_backend/cli.py
Normal file
@ -0,0 +1,24 @@
|
||||
"""CLI and main entry point."""
|
||||
|
||||
from pathlib import Path
|
||||
import click
|
||||
from pydantic import BaseModel, FilePath
|
||||
|
||||
|
||||
|
||||
|
||||
class BackendSettings(BaseModel):
|
||||
"""Backend Settings."""
|
||||
|
||||
db_file: FilePath
|
||||
regenerate_tokens: bool = False
|
||||
|
||||
|
||||
@click.group()
|
||||
@click.option("--db-file", envvar="sshecret_db_file", type=click.Path(path_type=Path))
|
||||
@click.option("--regenerate-tokens", is_flag=True, default=False)
|
||||
@click.pass_context
|
||||
def cli(ctx: click.Context, db_file: Path, regenerate_tokens: bool) -> None:
|
||||
"""Sshecret database handler."""
|
||||
if not isinstance(ctx.obj, BackendSettings):
|
||||
ctx.obj = BackendSettings(db_file=db_file, regenerate_tokens=regenerate_tokens)
|
||||
Reference in New Issue
Block a user