Skip to content

Commit c6a5342

Browse files
author
Bernardas Ališauskas
committed
update docs
1 parent d13fc06 commit c6a5342

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

ptredis

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
#!/usr/bin/env python3
2-
"""Start ptpython shell with redis object"""
2+
"""
3+
Start ptpython shell with redis object
4+
5+
License: GPLv3
6+
Author: Bernardas Ališauskas <[email protected]>
7+
"""
38
import inspect
49
import os
510
from pathlib import Path
611

712
import click
8-
from click import echo
9-
from redis import Redis
1013
from ptpython.repl import embed
14+
from redis import Redis
1115

1216

1317
@click.command()
@@ -24,19 +28,23 @@ from ptpython.repl import embed
2428
@click.option('-b', '--as_bytes', is_flag=True, help='do not decode responses')
2529
@click.option('-s', '--silent', is_flag=True, help='do not print stuff')
2630
def main(host, port, password, as_bytes, silent, history, database):
27-
# if silent:
28-
# echo = lambda v: None
31+
"""start ptpython shell with redis object and expanded commands"""
32+
if silent:
33+
echo = lambda v: None
34+
else:
35+
echo = click.echo
2936
redis = Redis(
3037
host=host,
3138
port=os.environ.get('REDIS_PORT'),
3239
password=os.environ.get('REDIS_PASS'),
3340
decode_responses=not as_bytes,
3441
db=database,
3542
)
43+
r = redis
3644
for attr_name in dir(redis):
3745
attr = getattr(redis, attr_name)
3846
if inspect.ismethod(attr) and not attr_name.startswith('_'):
39-
locals()[attr_name.upper()] = attr
47+
locals()[attr_name] = attr
4048
echo(f'connected to: {redis}')
4149
embed(
4250
vi_mode=True,

0 commit comments

Comments
 (0)