diff --git a/Makefile b/Makefile index 2929236..41908a6 100644 --- a/Makefile +++ b/Makefile @@ -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. diff --git a/rethinkdb/__init__.py b/rethinkdb/__init__.py index 801db47..d68ddfd 100644 --- a/rethinkdb/__init__.py +++ b/rethinkdb/__init__.py @@ -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. diff --git a/rethinkdb/ast.py b/rethinkdb/ast.py index 45e4324..b725dbe 100644 --- a/rethinkdb/ast.py +++ b/rethinkdb/ast.py @@ -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. diff --git a/rethinkdb/cli/__init__.py b/rethinkdb/cli/__init__.py index 7227375..e0a7af5 100644 --- a/rethinkdb/cli/__init__.py +++ b/rethinkdb/cli/__init__.py @@ -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. diff --git a/rethinkdb/cli/_dump.py b/rethinkdb/cli/_dump.py index 0563b9e..5786eaf 100644 --- a/rethinkdb/cli/_dump.py +++ b/rethinkdb/cli/_dump.py @@ -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. @@ -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. """ diff --git a/rethinkdb/cli/_export.py b/rethinkdb/cli/_export.py index 3002489..628c2fd 100644 --- a/rethinkdb/cli/_export.py +++ b/rethinkdb/cli/_export.py @@ -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. @@ -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. """ diff --git a/rethinkdb/cli/_import.py b/rethinkdb/cli/_import.py index 582e3fc..f07b15d 100644 --- a/rethinkdb/cli/_import.py +++ b/rethinkdb/cli/_import.py @@ -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. @@ -25,7 +25,8 @@ @click.command -def cmd_import(): +@click.pass_context +def cmd_import(ctx): """ Import loads data into a RethinkDB cluster. """ diff --git a/rethinkdb/cli/_index_rebuild.py b/rethinkdb/cli/_index_rebuild.py index 8c3bc1e..d368586 100644 --- a/rethinkdb/cli/_index_rebuild.py +++ b/rethinkdb/cli/_index_rebuild.py @@ -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. @@ -28,7 +28,8 @@ @click.command -def cmd_index_rebuild(): +@click.pass_context +def cmd_index_rebuild(ctx): """ Rebuild outdated secondary indexes. """ diff --git a/rethinkdb/cli/_repl.py b/rethinkdb/cli/_repl.py index 076a253..95b6de7 100644 --- a/rethinkdb/cli/_repl.py +++ b/rethinkdb/cli/_repl.py @@ -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. @@ -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}") diff --git a/rethinkdb/cli/_restore.py b/rethinkdb/cli/_restore.py index c1b4da2..709d198 100644 --- a/rethinkdb/cli/_restore.py +++ b/rethinkdb/cli/_restore.py @@ -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. @@ -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. """ diff --git a/rethinkdb/cli/main.py b/rethinkdb/cli/main.py index 5ea90d5..c72223f 100644 --- a/rethinkdb/cli/main.py +++ b/rethinkdb/cli/main.py @@ -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. @@ -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. """ @@ -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") diff --git a/rethinkdb/encoder.py b/rethinkdb/encoder.py index 2585a4a..2d57c8f 100644 --- a/rethinkdb/encoder.py +++ b/rethinkdb/encoder.py @@ -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. diff --git a/rethinkdb/errors.py b/rethinkdb/errors.py index 09ebc45..a6373ea 100644 --- a/rethinkdb/errors.py +++ b/rethinkdb/errors.py @@ -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. diff --git a/rethinkdb/handshake.py b/rethinkdb/handshake.py index edb68f9..dd24214 100644 --- a/rethinkdb/handshake.py +++ b/rethinkdb/handshake.py @@ -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. diff --git a/rethinkdb/query.py b/rethinkdb/query.py index dd2ee46..5c0f01b 100644 --- a/rethinkdb/query.py +++ b/rethinkdb/query.py @@ -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. diff --git a/rethinkdb/repl.py b/rethinkdb/repl.py index 1b313ac..8f58440 100644 --- a/rethinkdb/repl.py +++ b/rethinkdb/repl.py @@ -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. diff --git a/rethinkdb/utilities.py b/rethinkdb/utilities.py index 32aac83..8fc00e9 100644 --- a/rethinkdb/utilities.py +++ b/rethinkdb/utilities.py @@ -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. diff --git a/scripts/convert_protofile.py b/scripts/convert_protofile.py index b4f379f..73a90ea 100644 --- a/scripts/convert_protofile.py +++ b/scripts/convert_protofile.py @@ -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 diff --git a/tests/__init__.py b/tests/__init__.py index 839de75..d5b5ee0 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -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. diff --git a/tests/helpers.py b/tests/helpers.py index 65bd48c..7b9ca5c 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -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. diff --git a/tests/integration/test_ast.py b/tests/integration/test_ast.py index b5472b0..2efb983 100644 --- a/tests/integration/test_ast.py +++ b/tests/integration/test_ast.py @@ -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. diff --git a/tests/integration/test_queries.py b/tests/integration/test_queries.py index 67a0d89..bd47fa4 100644 --- a/tests/integration/test_queries.py +++ b/tests/integration/test_queries.py @@ -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. diff --git a/tests/integration/test_repl.py b/tests/integration/test_repl.py index a26b6cb..17f8f01 100644 --- a/tests/integration/test_repl.py +++ b/tests/integration/test_repl.py @@ -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. diff --git a/tests/test_date_and_time.py b/tests/test_date_and_time.py index fdf8a21..4ad1961 100644 --- a/tests/test_date_and_time.py +++ b/tests/test_date_and_time.py @@ -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. diff --git a/tests/test_encoder.py b/tests/test_encoder.py index e8fad1d..5f94fe7 100644 --- a/tests/test_encoder.py +++ b/tests/test_encoder.py @@ -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. diff --git a/tests/test_errors.py b/tests/test_errors.py index 3a66fe6..0a9077e 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -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. diff --git a/tests/test_handshake.py b/tests/test_handshake.py index 2754965..4cc1d12 100644 --- a/tests/test_handshake.py +++ b/tests/test_handshake.py @@ -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. diff --git a/tests/test_net.py b/tests/test_net.py index 55f0c5e..172957d 100644 --- a/tests/test_net.py +++ b/tests/test_net.py @@ -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. diff --git a/tests/test_query.py b/tests/test_query.py index cad350e..ec39004 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -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. diff --git a/tests/test_repl.py b/tests/test_repl.py index c1dd6e0..377598a 100644 --- a/tests/test_repl.py +++ b/tests/test_repl.py @@ -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. diff --git a/tests/test_utilities.py b/tests/test_utilities.py index e54698a..719abc9 100644 --- a/tests/test_utilities.py +++ b/tests/test_utilities.py @@ -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.