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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ $ hyaml
True
>>>
```
Your command history is stored in the `~/.hyaml_history` file.

## ANTLR

Expand Down
12 changes: 11 additions & 1 deletion hyaml/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
def main():
import os
import readline
from hyaml.translator import translate
from hyaml.compiler import compile_expression
from code import interact
Expand All @@ -7,4 +9,12 @@ def evaluate(expr, **lcls):
fn = compile_expression(expr, bindings=("variables",))
return fn(variables=lcls)

interact(local={"evaluate": evaluate, "translate": translate})
histfile = os.path.join(os.path.expanduser("~"), ".hyaml_history")
try:
readline.read_history_file(histfile)
except FileNotFoundError:
pass

interact(banner="HYAML Playgroud", local={"evaluate": evaluate, "translate": translate})

readline.write_history_file(histfile)