Merging upstream version 1.12.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
efb6cb056d
commit
66b78e69ac
17 changed files with 293 additions and 71 deletions
iredis
|
@ -123,22 +123,22 @@ def write_result(text, max_height=None):
|
|||
|
||||
class Rainbow:
|
||||
color = [
|
||||
("#cc2244"),
|
||||
("#bb4444"),
|
||||
("#996644"),
|
||||
("#cc8844"),
|
||||
("#ccaa44"),
|
||||
("#bbaa44"),
|
||||
("#99aa44"),
|
||||
("#778844"),
|
||||
("#55aa44"),
|
||||
("#33aa44"),
|
||||
("#11aa44"),
|
||||
("#11aa66"),
|
||||
("#11aa88"),
|
||||
("#11aaaa"),
|
||||
("#11aacc"),
|
||||
("#11aaee"),
|
||||
"#cc2244",
|
||||
"#bb4444",
|
||||
"#996644",
|
||||
"#cc8844",
|
||||
"#ccaa44",
|
||||
"#bbaa44",
|
||||
"#99aa44",
|
||||
"#778844",
|
||||
"#55aa44",
|
||||
"#33aa44",
|
||||
"#11aa44",
|
||||
"#11aa66",
|
||||
"#11aa88",
|
||||
"#11aaaa",
|
||||
"#11aacc",
|
||||
"#11aaee",
|
||||
]
|
||||
|
||||
def __init__(self):
|
||||
|
@ -160,8 +160,7 @@ class Rainbow:
|
|||
|
||||
|
||||
def prompt_message(client):
|
||||
# TODO custom prompt
|
||||
text = "{hostname}> ".format(hostname=str(client))
|
||||
text = str(client)
|
||||
if config.rainbow:
|
||||
return list(zip(Rainbow(), text))
|
||||
return text
|
||||
|
@ -248,8 +247,11 @@ PAGER_HELP = """Using pager when output is too tall for your window, default to
|
|||
@click.option(
|
||||
"-s", "--socket", default=None, help="Server socket (overrides hostname and port)."
|
||||
)
|
||||
@click.option("-n", help="Database number.(overwrites dsn/url's db number)", default=0)
|
||||
@click.option(
|
||||
"-n", help="Database number.(overwrites dsn/url's db number)", default=None
|
||||
"-u",
|
||||
"--username",
|
||||
help="User name used to auth, will be ignore for redis version < 6.",
|
||||
)
|
||||
@click.option("-a", "--password", help="Password to use when connecting to the server.")
|
||||
@click.option("--url", default=None, envvar="IREDIS_URL", help=URL_HELP)
|
||||
|
@ -271,6 +273,14 @@ PAGER_HELP = """Using pager when output is too tall for your window, default to
|
|||
@click.option("--rainbow/--no-rainbow", default=None, is_flag=True, help=RAINBOW)
|
||||
@click.option("--shell/--no-shell", default=None, is_flag=True, help=SHELL)
|
||||
@click.option("--pager/--no-pager", default=None, is_flag=True, help=PAGER_HELP)
|
||||
@click.option(
|
||||
"--prompt",
|
||||
default=None,
|
||||
help=(
|
||||
"Prompt format (supported interpolations: {client_name}, {db}, {host}, {path},"
|
||||
" {port}, {username}, {client_addr}, {client_id})."
|
||||
),
|
||||
)
|
||||
@click.version_option()
|
||||
@click.argument("cmd", nargs=-1)
|
||||
def gather_args(
|
||||
|
@ -278,6 +288,7 @@ def gather_args(
|
|||
h,
|
||||
p,
|
||||
n,
|
||||
username,
|
||||
password,
|
||||
client_name,
|
||||
newbie,
|
||||
|
@ -291,6 +302,7 @@ def gather_args(
|
|||
socket,
|
||||
shell,
|
||||
pager,
|
||||
prompt,
|
||||
):
|
||||
"""
|
||||
IRedis: Interactive Redis
|
||||
|
@ -311,9 +323,9 @@ def gather_args(
|
|||
load_config_files(iredisrc)
|
||||
setup_log()
|
||||
logger.info(
|
||||
f"[commandline args] host={h}, port={p}, db={n}, newbie={newbie}, "
|
||||
f"iredisrc={iredisrc}, decode={decode}, raw={raw}, "
|
||||
f"cmd={cmd}, rainbow={rainbow}."
|
||||
f"[commandline args] host={h}, port={p}, db={n}, user={username},"
|
||||
f" newbie={newbie}, iredisrc={iredisrc}, decode={decode}, raw={raw}, cmd={cmd},"
|
||||
f" rainbow={rainbow}."
|
||||
)
|
||||
# raw config
|
||||
if raw is not None:
|
||||
|
@ -368,8 +380,10 @@ def create_client(params):
|
|||
host = params["h"]
|
||||
port = params["p"]
|
||||
db = params["n"]
|
||||
username = params["username"]
|
||||
password = params["password"]
|
||||
client_name = params["client_name"]
|
||||
prompt = params["prompt"]
|
||||
|
||||
dsn_from_url = None
|
||||
dsn = params["dsn"]
|
||||
|
@ -390,17 +404,26 @@ def create_client(params):
|
|||
scheme=dsn_from_url.scheme,
|
||||
username=dsn_from_url.username,
|
||||
client_name=client_name,
|
||||
prompt=prompt,
|
||||
)
|
||||
if params["socket"]:
|
||||
return Client(
|
||||
scheme="unix",
|
||||
path=params["socket"],
|
||||
db=db,
|
||||
username=username,
|
||||
password=password,
|
||||
client_name=client_name,
|
||||
prompt=prompt,
|
||||
)
|
||||
return Client(
|
||||
host=host, port=port, db=db, password=password, client_name=client_name
|
||||
host=host,
|
||||
port=port,
|
||||
db=db,
|
||||
username=username,
|
||||
password=password,
|
||||
client_name=client_name,
|
||||
prompt=prompt,
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue