-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathcli.py
More file actions
83 lines (74 loc) · 2.28 KB
/
cli.py
File metadata and controls
83 lines (74 loc) · 2.28 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import warnings
warnings.filterwarnings(
"ignore", message="pkg_resources is deprecated as an API.", category=UserWarning
)
warnings.filterwarnings(
"ignore",
message=(
r"Protobuf gencode version [\d\.]+ is exactly one major version older than the runtime version [\d\.]+ at v1/tenants\.proto\. "
r"Please update the gencode to avoid compatibility violations in the next runtime release\."
),
category=UserWarning,
)
from typing import Optional
import click
import sys
from weaviate_cli.managers.config_manager import ConfigManager
from weaviate_cli.commands.create import create
from weaviate_cli.commands.delete import delete
from weaviate_cli.commands.get import get
from weaviate_cli.commands.update import update
from weaviate_cli.commands.query import query
from weaviate_cli.commands.restore import restore
from weaviate_cli.commands.cancel import cancel
from weaviate_cli.commands.assign import assign
from weaviate_cli.commands.revoke import revoke
from weaviate_cli.commands.benchmark import benchmark
from weaviate_cli import __version__
def print_version(ctx, param, value):
if not value or ctx.resilient_parsing:
return
click.echo(f"Weaviate CLI version {__version__}")
ctx.exit()
@click.group()
@click.option(
"--config-file",
required=False,
type=click.Path(exists=True),
is_flag=False,
help="If specified cli uses the config specified with this path.",
)
@click.option(
"--user",
required=False,
type=str,
help="If specified cli uses the user specified in the config file.",
)
@click.option(
"--version",
is_flag=True,
callback=print_version,
expose_value=False,
is_eager=True,
help="Prints the version of the CLI.",
)
@click.pass_context
def main(ctx: click.Context, config_file: Optional[str], user: Optional[str]):
"""Weaviate CLI tool"""
try:
ctx.obj = {"config": ConfigManager(config_file, user)}
except Exception as e:
click.echo(f"Fatal Error: {e}")
sys.exit(1)
main.add_command(create)
main.add_command(delete)
main.add_command(get)
main.add_command(update)
main.add_command(restore)
main.add_command(query)
main.add_command(cancel)
main.add_command(assign)
main.add_command(revoke)
main.add_command(benchmark)
if __name__ == "__main__":
main()