Skip to content

Commit

Permalink
fix handling of empty input #185
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu-g committed Jul 28, 2023
1 parent 2bc13d8 commit 3d33347
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/kwja/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,9 @@ def main(
if input_text is not None:
if input_text.strip() != "":
print(processor.run(_split_into_documents(input_text)), end="")
processor.refresh()
processor.refresh()
else:
print("EOD")
raise typer.Exit()

# Interactive mode
Expand All @@ -385,11 +387,14 @@ def main(
except EOFError:
break
if input_ == "EOD":
processor.refresh()
print(processor.run([input_text], interactive=True), end="")
if specified_tasks != ["typo"]:
print("EOD") # To indicate the end of the output.
input_text = ""
if input_text.strip() != "":
processor.refresh()
print(processor.run([input_text], interactive=True), end="")
if specified_tasks != ["typo"]:
print("EOD") # To indicate the end of the output.
input_text = ""
else:
print("EOD")
else:
input_text += input_ + "\n"

Expand Down
2 changes: 1 addition & 1 deletion tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_text_input():
@pytest.mark.parametrize(
"text, output",
[
("", ""),
("", "EOD\n"),
# ("EOD", "EOD\nEOD\n"), # TODO
("おはよう", "おはよう\nEOD\n"),
("おはよう.", "おはよう.\nEOD\n"),
Expand Down

0 comments on commit 3d33347

Please sign in to comment.