Skip to content

Commit 1b9ce09

Browse files
committed
feat(wip): prepare to implement commands
Signed-off-by: Gabor Boros <gabor.brs@gmail.com>
1 parent abbefd7 commit 1b9ce09

31 files changed

+91
-50
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

rethinkdb/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

rethinkdb/ast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

rethinkdb/cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

rethinkdb/cli/_dump.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
# Copyright 2022 RethinkDB
3+
# Copyright 2022 - present RethinkDB
44
#
55
# Licensed under the Apache License, Version 2.0 (the 'License');
66
# you may not use this file except in compliance with the License.
@@ -20,11 +20,13 @@
2020
"""
2121
Dump creates an archive of data from a RethinkDB cluster.
2222
"""
23+
2324
import click
2425

2526

2627
@click.command
27-
def cmd_dump():
28+
@click.pass_context
29+
def cmd_dump(ctx):
2830
"""
2931
Dump creates an archive of data from a RethinkDB cluster.
3032
"""

rethinkdb/cli/_export.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
# Copyright 2022 RethinkDB
3+
# Copyright 2022 - present RethinkDB
44
#
55
# Licensed under the Apache License, Version 2.0 (the 'License');
66
# you may not use this file except in compliance with the License.
@@ -20,11 +20,13 @@
2020
"""
2121
Export exports data from a RethinkDB cluster into a directory.
2222
"""
23+
2324
import click
2425

2526

2627
@click.command
27-
def cmd_export():
28+
@click.pass_context
29+
def cmd_export(ctx):
2830
"""
2931
Export data from a RethinkDB cluster into a directory.
3032
"""

rethinkdb/cli/_import.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
# Copyright 2022 RethinkDB
3+
# Copyright 2022 - present RethinkDB
44
#
55
# Licensed under the Apache License, Version 2.0 (the 'License');
66
# you may not use this file except in compliance with the License.
@@ -25,7 +25,8 @@
2525

2626

2727
@click.command
28-
def cmd_import():
28+
@click.pass_context
29+
def cmd_import(ctx):
2930
"""
3031
Import loads data into a RethinkDB cluster.
3132
"""

rethinkdb/cli/_index_rebuild.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
# Copyright 2022 RethinkDB
3+
# Copyright 2022 - present RethinkDB
44
#
55
# Licensed under the Apache License, Version 2.0 (the 'License');
66
# you may not use this file except in compliance with the License.
@@ -28,7 +28,8 @@
2828

2929

3030
@click.command
31-
def cmd_index_rebuild():
31+
@click.pass_context
32+
def cmd_index_rebuild(ctx):
3233
"""
3334
Rebuild outdated secondary indexes.
3435
"""

rethinkdb/cli/_repl.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
# Copyright 2022 RethinkDB
3+
# Copyright 2022 - present RethinkDB
44
#
55
# Licensed under the Apache License, Version 2.0 (the 'License');
66
# you may not use this file except in compliance with the License.
@@ -18,24 +18,24 @@
1818
# Copyright 2010-2016 RethinkDB, all rights reserved.
1919

2020
"""
21-
The main command is a special group that is the root of the command tree.
22-
23-
This command creates a subcommand tree that with the following commands for
24-
those cases when the rethinkdb binary is not installed:
25-
- dump
26-
- export
27-
- import
28-
- index_rebuild
29-
- repl
30-
- restore
21+
Start an interactive Python shell (repl) with the RethinkDB driver imported.
3122
"""
3223

3324
import click
3425

26+
BANNER = """
27+
The RethinkDB driver has been imported as `r`.
28+
29+
A connection to %s:%d has been established as `conn`
30+
and can be used by calling `run()` on a query without any arguments.
31+
"""
3532

3633
@click.command
37-
def cmd_repl():
34+
@click.pass_context
35+
def cmd_repl(ctx):
3836
"""
39-
Rebuild outdated secondary indexes.
37+
Start an interactive Python shell (repl) with the RethinkDB driver imported.
4038
"""
41-
click.echo("repl command")
39+
40+
click.echo(f"repl command: {ctx}")
41+

rethinkdb/cli/_restore.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
# Copyright 2022 RethinkDB
3+
# Copyright 2022 - present RethinkDB
44
#
55
# Licensed under the Apache License, Version 2.0 (the 'License');
66
# you may not use this file except in compliance with the License.
@@ -25,7 +25,8 @@
2525

2626

2727
@click.command
28-
def cmd_restore():
28+
@click.pass_context
29+
def cmd_restore(ctx):
2930
"""
3031
Restore loads data into a RethinkDB cluster from an archive.
3132
"""

rethinkdb/cli/main.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
# Copyright 2022 RethinkDB
3+
# Copyright 2022 - present RethinkDB
44
#
55
# Licensed under the Apache License, Version 2.0 (the 'License');
66
# you may not use this file except in compliance with the License.
@@ -43,7 +43,38 @@
4343

4444

4545
@click.group
46-
def cmd_main():
46+
@click.option(
47+
"--debug",
48+
default=False,
49+
help="Print debug information.",
50+
envvar="RETHINKDB_DEBUG",
51+
type=click.BOOL,
52+
)
53+
@click.option(
54+
"--user",
55+
"-u",
56+
default="admin",
57+
help="The RethinkDB user to connect with.",
58+
envvar="RETHINKDB_USER",
59+
type=click.STRING,
60+
)
61+
@click.option(
62+
"--host",
63+
"-h",
64+
default="localhost",
65+
help="The RethinkDB host to connect to.",
66+
envvar="RETHINKDB_HOSTNAME",
67+
type=click.STRING,
68+
)
69+
@click.option(
70+
"--port",
71+
"-p",
72+
default=28015,
73+
help="The RethinkDB driver port to connect to.",
74+
envvar="RETHINKDB_DRIVER_PORT",
75+
type=click.INT,
76+
)
77+
def cmd_main(*args, **kwargs):
4778
"""
4879
Group of commands for the RethinkDB database.
4980
"""
@@ -55,3 +86,6 @@ def cmd_main():
5586
cmd_main.add_command(cmd_index_rebuild, "index_rebuild")
5687
cmd_main.add_command(cmd_repl, "repl")
5788
cmd_main.add_command(cmd_restore, "restore")
89+
90+
if __name__ == "__main__":
91+
cmd_main(auto_envvar_prefix="RETHINKDB")

rethinkdb/encoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

rethinkdb/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

rethinkdb/handshake.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

rethinkdb/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

rethinkdb/repl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

rethinkdb/utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

scripts/convert_protofile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use
44
# this file except in compliance with the License. You may obtain a copy of the

tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

tests/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

tests/integration/test_ast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

tests/integration/test_queries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

tests/integration/test_repl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

tests/test_date_and_time.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

tests/test_encoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

tests/test_errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

tests/test_handshake.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

tests/test_net.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

tests/test_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

tests/test_repl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

tests/test_utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 RethinkDB
1+
# Copyright 2022 - present RethinkDB
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)