Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Bug Fixes

- Expand `~` in configured log file paths before opening the log.
- Print the usage message instead of raising `RuntimeError` when `watch` is run without a query.

### Internal

Expand Down
8 changes: 4 additions & 4 deletions litecli/packages/special/iocommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def watch_query(arg: str, **kwargs: Any) -> Generator[tuple, None, None]:
"""
if not arg:
yield (None, None, None, usage)
raise StopIteration
return
seconds: float = 5.0
clear_screen = False
statement = None
Expand All @@ -476,7 +476,7 @@ def watch_query(arg: str, **kwargs: Any) -> Generator[tuple, None, None]:
if not arg:
# Oops, we parsed all the arguments without finding a statement
yield (None, None, None, usage)
raise StopIteration
return
(current_arg, _, arg) = arg.partition(" ")
try:
seconds = float(current_arg)
Expand All @@ -490,7 +490,7 @@ def watch_query(arg: str, **kwargs: Any) -> Generator[tuple, None, None]:
destructive_prompt = confirm_destructive_query(statement)
if destructive_prompt is False:
click.secho("Wise choice!")
raise StopIteration
return
elif destructive_prompt is True:
click.secho("Your call!")
cur = kwargs["cur"]
Expand All @@ -515,6 +515,6 @@ def watch_query(arg: str, **kwargs: Any) -> Generator[tuple, None, None]:
# This prints the Ctrl-C character in its own line, which prevents
# to print a line with the cursor positioned behind the prompt
click.secho("", nl=True)
raise StopIteration
return
finally:
set_pager_enabled(old_pager_enabled)
7 changes: 7 additions & 0 deletions tests/test_special_iocommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,10 @@ def test_parse_special_command_edge_cases():
sql = r"\llm+- Question"
# '+' in command sets verbosity; strip('+-') removes both suffixes
assert parse_special_command(sql) == ("\\llm", Verbosity.VERBOSE, "Question")


@pytest.mark.parametrize("command", ["watch", "watch -c", "watch 3"])
def test_watch_without_a_query_prints_usage(command):
results = list(litecli.packages.special.execute(None, command))
assert len(results) == 1
assert results[0][3].startswith("Syntax: watch")