Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2c5951a

Browse files
authored
feat: add command base (#279)
Signed-off-by: Gabor Boros <gabor.brs@gmail.com>
1 parent099fa8c commit2c5951a

File tree

11 files changed

+305
-8
lines changed

11 files changed

+305
-8
lines changed

‎.flake8‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ ignore=E203,E501,W503
33
max-line-length=88
44
application_import_names=rethinkdb
55
exclude = .git,__pycache__,tests
6+
per-file-ignores =
7+
rethinkdb/cli/__init__.py: F401

‎poetry.lock‎

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎pyproject.toml‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,22 @@ maintainers = [
3636
[tool.poetry.urls]
3737
"Bug Tracker" ="https://github.com/rethinkdb/rethinkdb-python/issues/"
3838

39-
# this should be shipped with the C++ code not the python client
40-
# [tool.poetry.scripts]
41-
# rethinkdb-import = 'rethinkdb.main:app'
39+
# RethinkDB is aliasing the commands to `rethinkdb <command>`, therefore it
40+
# can be executed as `rethinkdb dump` or `rethinkdb-dump`.
41+
[tool.poetry.scripts]
42+
rethinkdb ="rethinkdb.cli.main:cmd_main"
43+
rethinkdb-dump ="rethinkdb.cli._dump:cmd_dump"
44+
rethinkdb-export ="rethinkdb.cli._export:cmd_export"
45+
rethinkdb-import ="rethinkdb.cli._import:cmd_import"
46+
rethinkdb-index-rebuild ="rethinkdb.cli._index_rebuild:cmd_index_rebuild"
47+
rethinkdb-repl ="rethinkdb.cli._repl:cmd_repl"
48+
rethinkdb-restore ="rethinkdb.cli._restore:cmd_restore"
4249

4350
[tool.poetry.dependencies]
4451
pydantic ="^1.9"
4552
python ="^3.7"
4653
ujson ="^5.2.0"
54+
click ="^8.1.3"
4755

4856
[tool.poetry.dev-dependencies]
4957
bandit ="^1.7"

‎rethinkdb/cli/__init__.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2022 RethinkDB
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the 'License');
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an 'AS IS' BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""
16+
RethinkDB CLI module defines the management commands that can be used to
17+
interact with the database. These commands are for exporting/importing data.
18+
19+
Although these commands can be used to prepare data for backup, depending on
20+
your needs, you may want to evaluate more mature backup backup solutions.
21+
"""
22+
23+
fromrethinkdb.cli._dumpimportcmd_dump
24+
fromrethinkdb.cli._exportimportcmd_export
25+
fromrethinkdb.cli._importimportcmd_import
26+
fromrethinkdb.cli._index_rebuildimportcmd_index_rebuild
27+
fromrethinkdb.cli._replimportcmd_repl
28+
fromrethinkdb.cli._restoreimportcmd_restore

‎rethinkdb/cli/_dump.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright 2022 RethinkDB
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the 'License');
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an 'AS IS' BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# This file incorporates work covered by the following copyright:
18+
# Copyright 2010-2016 RethinkDB, all rights reserved.
19+
20+
"""
21+
Dump creates an archive of data from a RethinkDB cluster.
22+
"""
23+
importclick
24+
25+
26+
@click.command
27+
defcmd_dump():
28+
"""
29+
Dump creates an archive of data from a RethinkDB cluster.
30+
"""
31+
click.echo("dump command")

‎rethinkdb/cli/_export.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright 2022 RethinkDB
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the 'License');
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an 'AS IS' BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# This file incorporates work covered by the following copyright:
18+
# Copyright 2010-2016 RethinkDB, all rights reserved.
19+
20+
"""
21+
Export exports data from a RethinkDB cluster into a directory.
22+
"""
23+
importclick
24+
25+
26+
@click.command
27+
defcmd_export():
28+
"""
29+
Export data from a RethinkDB cluster into a directory.
30+
"""
31+
click.echo("export command")

‎rethinkdb/cli/_import.py‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright 2022 RethinkDB
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the 'License');
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an 'AS IS' BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# This file incorporates work covered by the following copyright:
18+
# Copyright 2010-2016 RethinkDB, all rights reserved.
19+
20+
"""
21+
Import loads data into a RethinkDB cluster.
22+
"""
23+
24+
importclick
25+
26+
27+
@click.command
28+
defcmd_import():
29+
"""
30+
Import loads data into a RethinkDB cluster.
31+
"""
32+
click.echo("import command")

‎rethinkdb/cli/_index_rebuild.py‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright 2022 RethinkDB
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the 'License');
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an 'AS IS' BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# This file incorporates work covered by the following copyright:
18+
# Copyright 2010-2016 RethinkDB, all rights reserved.
19+
20+
"""
21+
Index rebuild recreates outdated secondary indexes in a cluster.
22+
23+
This should be used after upgrading to a newer version of rethinkdb. There
24+
will be a notification in the web UI if any secondary indexes are out-of-date.
25+
"""
26+
27+
importclick
28+
29+
30+
@click.command
31+
defcmd_index_rebuild():
32+
"""
33+
Rebuild outdated secondary indexes.
34+
"""
35+
click.echo("index rebuild command")

‎rethinkdb/cli/_repl.py‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright 2022 RethinkDB
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the 'License');
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an 'AS IS' BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# This file incorporates work covered by the following copyright:
18+
# Copyright 2010-2016 RethinkDB, all rights reserved.
19+
20+
"""
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
31+
"""
32+
33+
importclick
34+
35+
36+
@click.command
37+
defcmd_repl():
38+
"""
39+
Rebuild outdated secondary indexes.
40+
"""
41+
click.echo("repl command")

‎rethinkdb/cli/_restore.py‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright 2022 RethinkDB
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the 'License');
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an 'AS IS' BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# This file incorporates work covered by the following copyright:
18+
# Copyright 2010-2016 RethinkDB, all rights reserved.
19+
20+
"""
21+
Restore loads data into a RethinkDB cluster from an archive.
22+
"""
23+
24+
importclick
25+
26+
27+
@click.command
28+
defcmd_restore():
29+
"""
30+
Restore loads data into a RethinkDB cluster from an archive.
31+
"""
32+
click.echo("restore command")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp