-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget.py
More file actions
30 lines (25 loc) · 1.16 KB
/
get.py
File metadata and controls
30 lines (25 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import typer
app = typer.Typer()
@app.command("get")
def get_provider(
connection_type: str = typer.Option(None, "--type", "-t", help="The type of the provider to get."),
name: str = typer.Option(None, "--name", "-n", help="The name of the provider to get."),
):
"""Get connection information for a provider by name or by type.
If both options are provided, it will search for providers matching either criterion."""
from docbinder_oss.helpers.config import load_config
config = load_config()
provider_found = False
if not config.providers:
typer.echo("No providers configured.")
raise typer.Exit(code=1)
for provider in config.providers:
if provider.name == name:
typer.echo(f"Provider '{name}' found with config: {provider}")
provider_found = True
if provider.type == connection_type:
typer.echo(f"Provider '{provider.name}' of type '{connection_type}'" f" found with config: {provider}")
provider_found = True
if not provider_found:
typer.echo(f"No providers found with name '{name}' or type '{connection_type}'.")
raise typer.Exit(code=1)