Skip to content

Commit

Permalink
Add pattern output on exit (#26)
Browse files Browse the repository at this point in the history
Co-authored-by: Ari Donnenfeld <[email protected]>
  • Loading branch information
ari-donnenfeld and Ari Donnenfeld authored Aug 14, 2024
1 parent 88a2f5f commit 012e8a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions rexi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ def rexi_cli(
input_text, initial_mode=initial_mode, initial_pattern=initial_pattern
)
app.run()
print(app.pattern)
5 changes: 3 additions & 2 deletions rexi/rexi.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ def __init__(
self.input_content: str = input_content
self.regex_modes: list[str] = RexiApp.AVAILABLE_MODES
self.regex_current_mode: str = initial_mode
self.initial_pattern = initial_pattern
self.pattern = initial_pattern

def compose(self) -> ComposeResult:
with Horizontal(id="inputs"):
yield Input(value=self.initial_pattern, placeholder="Enter regex pattern")
yield Input(value=self.pattern, placeholder="Enter regex pattern")
yield Select(
zip(self.regex_modes, self.regex_modes),
id="select",
Expand All @@ -80,6 +80,7 @@ def compose(self) -> ComposeResult:

@on(Input.Changed)
async def on_input_changed(self, message: Input.Changed) -> None:
self.pattern = message.value
self.run_worker(self.update_regex(message.value), exclusive=True)

@on(Select.Changed)
Expand Down

0 comments on commit 012e8a8

Please sign in to comment.