diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-08-15 12:04:47 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-08-15 12:04:47 +0000 |
commit | 69829819561dd586ad38aeb10ed71ca0771b9d7a (patch) | |
tree | d0e1796fcbc62101389684c576dd4fe282b88715 /iredis/entry.py | |
parent | Releasing debian version 1.12.0-1. (diff) | |
download | iredis-69829819561dd586ad38aeb10ed71ca0771b9d7a.tar.xz iredis-69829819561dd586ad38aeb10ed71ca0771b9d7a.zip |
Merging upstream version 1.12.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'iredis/entry.py')
-rw-r--r-- | iredis/entry.py | 69 |
1 files changed, 46 insertions, 23 deletions
diff --git a/iredis/entry.py b/iredis/entry.py index 2a9dc05..9a07956 100644 --- a/iredis/entry.py +++ b/iredis/entry.py @@ -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, ) |