Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to disable greetings information #475

Merged
merged 7 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,17 +23,19 @@

### 1.12.2

- Feature: IRedis now honors the `ssl_cert_reqs` strategy, either specifying it via
command line (`--verify-ssl=<none|optional|required>`) 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=<none|optional|required>`) or as an url
parameter (`ssl_cert_reqs`) when the connection is secured via tls
(`rediss://`). (authored by [torrefatto])

### 1.12.1

- Feature: support new command: `HRANDFIELD`.
- 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

Expand Down
3 changes: 3 additions & 0 deletions iredis/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def __init__(self):
self.withscores = False
self.version = "Unknown"

self.greetings = True

self.prompt = None

def __setter__(self, name, value):
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions iredis/data/iredisrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 16 additions & 6 deletions iredis/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -274,6 +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(
"--verify-ssl",
default=None,
Expand Down Expand Up @@ -309,6 +315,7 @@ def gather_args(
socket,
shell,
pager,
greetings,
verify_ssl,
prompt,
):
Expand Down Expand Up @@ -354,6 +361,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

Expand Down Expand Up @@ -492,5 +501,6 @@ def main():
)

# print hello message
greetings()
if config.greetings:
greetings()
repl(client, session, enter_main_time)
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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()

Expand Down
Loading