Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wip): prepare to implement commands #287

Open
wants to merge 3 commits into
base: gabor/python3-v2.5.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion rethinkdb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion rethinkdb/ast.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion rethinkdb/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
6 changes: 4 additions & 2 deletions rethinkdb/cli/_dump.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand All @@ -20,11 +20,13 @@
"""
Dump creates an archive of data from a RethinkDB cluster.
"""

import click


@click.command
def cmd_dump():
@click.pass_context
def cmd_dump(ctx):
"""
Dump creates an archive of data from a RethinkDB cluster.
"""
Expand Down
6 changes: 4 additions & 2 deletions rethinkdb/cli/_export.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand All @@ -20,11 +20,13 @@
"""
Export exports data from a RethinkDB cluster into a directory.
"""

import click


@click.command
def cmd_export():
@click.pass_context
def cmd_export(ctx):
"""
Export data from a RethinkDB cluster into a directory.
"""
Expand Down
5 changes: 3 additions & 2 deletions rethinkdb/cli/_import.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

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


@click.command
def cmd_import():
@click.pass_context
def cmd_import(ctx):
"""
Import loads data into a RethinkDB cluster.
"""
Expand Down
5 changes: 3 additions & 2 deletions rethinkdb/cli/_index_rebuild.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

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


@click.command
def cmd_index_rebuild():
@click.pass_context
def cmd_index_rebuild(ctx):
"""
Rebuild outdated secondary indexes.
"""
Expand Down
27 changes: 13 additions & 14 deletions rethinkdb/cli/_repl.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

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

"""
The main command is a special group that is the root of the command tree.

This command creates a subcommand tree that with the following commands for
those cases when the rethinkdb binary is not installed:
- dump
- export
- import
- index_rebuild
- repl
- restore
Start an interactive Python shell (repl) with the RethinkDB driver imported.
"""

import click

BANNER = """
The RethinkDB driver has been imported as `r`.

A connection to %s:%d has been established as `conn`
and can be used by calling `run()` on a query without any arguments.
"""

@click.command
def cmd_repl():
@click.pass_context
def cmd_repl(ctx):
"""
Rebuild outdated secondary indexes.
Start an interactive Python shell (repl) with the RethinkDB driver imported.
"""
click.echo("repl command")

click.echo(f"repl command: {ctx}")
5 changes: 3 additions & 2 deletions rethinkdb/cli/_restore.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

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


@click.command
def cmd_restore():
@click.pass_context
def cmd_restore(ctx):
"""
Restore loads data into a RethinkDB cluster from an archive.
"""
Expand Down
38 changes: 36 additions & 2 deletions rethinkdb/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

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


@click.group
def cmd_main():
@click.option(
"--debug",
default=False,
help="Print debug information.",
envvar="RETHINKDB_DEBUG",
type=click.BOOL,
)
@click.option(
"--user",
"-u",
default="admin",
help="The RethinkDB user to connect with.",
envvar="RETHINKDB_USER",
type=click.STRING,
)
@click.option(
"--host",
"-h",
default="localhost",
help="The RethinkDB host to connect to.",
envvar="RETHINKDB_HOSTNAME",
type=click.STRING,
)
@click.option(
"--port",
"-p",
default=28015,
help="The RethinkDB driver port to connect to.",
envvar="RETHINKDB_DRIVER_PORT",
type=click.INT,
)
def cmd_main(*args, **kwargs):
"""
Group of commands for the RethinkDB database.
"""
Expand All @@ -55,3 +86,6 @@ def cmd_main():
cmd_main.add_command(cmd_index_rebuild, "index_rebuild")
cmd_main.add_command(cmd_repl, "repl")
cmd_main.add_command(cmd_restore, "restore")

if __name__ == "__main__":
cmd_main(auto_envvar_prefix="RETHINKDB")
2 changes: 1 addition & 1 deletion rethinkdb/encoder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion rethinkdb/errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion rethinkdb/handshake.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion rethinkdb/query.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion rethinkdb/repl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion rethinkdb/utilities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion scripts/convert_protofile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_ast.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_queries.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_repl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_date_and_time.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_encoder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_handshake.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_net.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_query.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_repl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utilities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 RethinkDB
# Copyright 2022 - present RethinkDB
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down