From abdbe799dfd9241a8bf253ce3b3bd29c9e4572dc Mon Sep 17 00:00:00 2001 From: laixintao Date: Mon, 25 Sep 2023 00:19:40 +0800 Subject: [PATCH 1/7] add option to disable greetings information close https://github.com/laixintao/iredis/issues/474 --- iredis/config.py | 3 +++ iredis/data/iredisrc | 4 ++++ iredis/entry.py | 11 ++++++++--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/iredis/config.py b/iredis/config.py index ff31d4e5..4041bb65 100644 --- a/iredis/config.py +++ b/iredis/config.py @@ -63,6 +63,8 @@ def __init__(self): self.withscores = False self.version = "Unknown" + self.greetings = True + self.prompt = None def __setter__(self, name, value): @@ -129,5 +131,6 @@ def load_config_files(iredisrc): config.pager = config_obj["main"].get("pager") config.enable_pager = config_obj["main"].as_bool("enable_pager") config.prompt = config_obj["main"].get("prompt") + config.greetings = config_obj["main"].as_bool("greetings") return config_obj diff --git a/iredis/data/iredisrc b/iredis/data/iredisrc index 6db02a71..978aa4be 100644 --- a/iredis/data/iredisrc +++ b/iredis/data/iredisrc @@ -76,6 +76,10 @@ prompt = # History file location history_location = ~/.iredis_history +# if set to True, will display version information on startup +# can set to False to disable it. +greetings = True + [alias_dsn] # example_dsn = redis://[[username]:[password]]@localhost:6379/0 # example_dsn = rediss://[[username]:[password]]@localhost:6379/0 diff --git a/iredis/entry.py b/iredis/entry.py index c7ae76ca..ee8591e7 100644 --- a/iredis/entry.py +++ b/iredis/entry.py @@ -61,8 +61,8 @@ def greetings(): reason = "" server_version = f"redis-server {config.version} {reason}" - home_page = "Home: https://iredis.io" - issues = "Issues: https://iredis.io/issues" + home_page = "Home: https://iredis.xbin.io/" + issues = "Issues: https://github.com/laixintao/iredis/issues" display = "\n".join([iredis_version, server_version, home_page, issues]) if config.raw: display = display.encode() @@ -274,6 +274,7 @@ def repl(client, session, start_time): @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("--greetings/--no-greetings", default=None, is_flag=True, help="Enable or disable greeting messages") @click.option( "--verify-ssl", default=None, @@ -309,6 +310,7 @@ def gather_args( socket, shell, pager, + greetings, verify_ssl, prompt, ): @@ -354,6 +356,8 @@ def gather_args( config.enable_pager = pager if verify_ssl is not None: config.verify_ssl = verify_ssl + if greetings is not None: + config.greetings = greetings return ctx @@ -492,5 +496,6 @@ def main(): ) # print hello message - greetings() + if config.greetings: + greetings() repl(client, session, enter_main_time) From ee8dc651a9161722d38ce13fb10ed315d4374609 Mon Sep 17 00:00:00 2001 From: laixintao Date: Mon, 25 Sep 2023 00:24:41 +0800 Subject: [PATCH 2/7] extend timeout --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index b70bf95c..c46d858b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -14,7 +14,7 @@ from iredis.config import Config, config as global_config -TIMEOUT = 2 +TIMEOUT = 10 HISTORY_FILE = ".iredis_history" From b66414d2b451085255d3343f53356107d9f71a5c Mon Sep 17 00:00:00 2001 From: laixintao Date: Mon, 25 Sep 2023 00:25:32 +0800 Subject: [PATCH 3/7] update changelog. --- CHANGELOG.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a116ea88..c98e9f2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ ## 1.13.2 - Dependency: upgrade markdown render mistune to v3 -- Dependency: deprecated importlib_resources, use Python build in `importlib.resources` now +- Dependency: deprecated importlib_resources, use Python build in + `importlib.resources` now - Dependency: upgrade redis-py to 4.5 - Doc: update homepage link to iredis.xbin.io - Bugfix: Fix restore command caused by string literal escape @@ -22,9 +23,10 @@ ### 1.12.2 -- Feature: IRedis now honors the `ssl_cert_reqs` strategy, either specifying it via - command line (`--verify-ssl=`) or as an url parameter (`ssl_cert_reqs`) - when the connection is secured via tls (`rediss://`). (authored by [torrefatto]) +- Feature: IRedis now honors the `ssl_cert_reqs` strategy, either specifying it + via command line (`--verify-ssl=`) or as an url + parameter (`ssl_cert_reqs`) when the connection is secured via tls + (`rediss://`). (authored by [torrefatto]) ### 1.12.1 @@ -32,7 +34,8 @@ - Bugfix: all tests pass on redis:7 now. - Feature: IRedis now accept `username` for auth, redis server version under 6 will ignore `username`. -- Feature: IRedis support prompt now, you can customize prompt string. (thanks to [aymericbeaumet]) +- Feature: IRedis support prompt now, you can customize prompt string. (thanks + to [aymericbeaumet]) ## 1.12 From 549254f8fd055a394a27178fc35133bc39b55f28 Mon Sep 17 00:00:00 2001 From: laixintao Date: Mon, 25 Sep 2023 00:26:47 +0800 Subject: [PATCH 4/7] black format. --- iredis/entry.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/iredis/entry.py b/iredis/entry.py index ee8591e7..9c83a66b 100644 --- a/iredis/entry.py +++ b/iredis/entry.py @@ -177,9 +177,9 @@ def repl(client, session, start_time): try: command = session.prompt( prompt_message(client), - bottom_toolbar=BottomToolbar(command_holder).render - if config.bottom_bar - else None, + bottom_toolbar=( + BottomToolbar(command_holder).render if config.bottom_bar else None + ), input_processors=[ UpdateBottomProcessor(command_holder, session), PasswordProcessor(), @@ -274,7 +274,12 @@ def repl(client, session, start_time): @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("--greetings/--no-greetings", default=None, is_flag=True, help="Enable or disable greeting messages") +@click.option( + "--greetings/--no-greetings", + default=None, + is_flag=True, + help="Enable or disable greeting messages", +) @click.option( "--verify-ssl", default=None, @@ -376,9 +381,11 @@ def resolve_dsn(dsn): dsn_uri = config.alias_dsn[dsn] except KeyError: click.secho( - "Could not find the specified DSN in the config file. " - 'Please check the "[alias_dsn]" section in your ' - "iredisrc.", + ( + "Could not find the specified DSN in the config file. " + 'Please check the "[alias_dsn]" section in your ' + "iredisrc." + ), err=True, fg="red", ) From aff4f638e59fc69227dbc95b269e1c23f48f0fbf Mon Sep 17 00:00:00 2001 From: laixintao Date: Sat, 7 Oct 2023 01:20:13 +0800 Subject: [PATCH 5/7] format with black --- iredis/entry.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/iredis/entry.py b/iredis/entry.py index 9c83a66b..0799a078 100644 --- a/iredis/entry.py +++ b/iredis/entry.py @@ -381,11 +381,9 @@ def resolve_dsn(dsn): dsn_uri = config.alias_dsn[dsn] except KeyError: click.secho( - ( - "Could not find the specified DSN in the config file. " - 'Please check the "[alias_dsn]" section in your ' - "iredisrc." - ), + "Could not find the specified DSN in the config file. " + 'Please check the "[alias_dsn]" section in your ' + "iredisrc.", err=True, fg="red", ) From 4e7e6bcf69d67915351650eff7956962b4f69d10 Mon Sep 17 00:00:00 2001 From: laixintao Date: Tue, 31 Oct 2023 14:41:29 +0800 Subject: [PATCH 6/7] fix iredis domain in conftest --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index c46d858b..b70bf95c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -14,7 +14,7 @@ from iredis.config import Config, config as global_config -TIMEOUT = 10 +TIMEOUT = 2 HISTORY_FILE = ".iredis_history" From 0fe0de4f130fb551a329f71af2fe6dff5a1a357a Mon Sep 17 00:00:00 2001 From: laixintao Date: Tue, 31 Oct 2023 14:45:42 +0800 Subject: [PATCH 7/7] fix conftest --- tests/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index b70bf95c..593e8a88 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -105,7 +105,7 @@ def cli(): child = pexpect.spawn(f"iredis -n 15 --iredisrc {f.name}", timeout=TIMEOUT, env=env) child.logfile_read = open("cli_test.log", "ab") - child.expect(["https://iredis.io/issues", "127.0.0.1"]) + child.expect(["https://github.com/laixintao/iredis/issues", "127.0.0.1"]) yield child child.close() @@ -129,7 +129,7 @@ def raw_cli(): f"iredis --raw -n 15 --iredisrc {TEST_IREDISRC}", timeout=TIMEOUT ) child.logfile_read = open("cli_test.log", "ab") - child.expect(["https://iredis.io/issues", "127.0.0.1"]) + child.expect(["https://github.com/laixintao/iredis/issues", "127.0.0.1"]) yield child child.close()