Skip to content

Commit

Permalink
basic command support
Browse files Browse the repository at this point in the history
  • Loading branch information
Henri Binsztok committed Jan 19, 2012
1 parent 4480d83 commit 1f171c1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion webshell.opa
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,21 @@ client function loop(_) {
LineEditor.init(#editor, readevalwrite, true);
}

function answer(expr) {
match (Parser.try_parse(Calc.shell, expr)) {
case { none }: "syntax error"
case { some: { value: result } }: "{result}"
case { some: { ~command, ~arg } }: "{command}({arg})"
}
}

client function readevalwrite(expr) {
element =
<div>
<span>{prompt({none})}</span>
<span>{expr}</span>
</div>
<div>{Calc.compute(expr)}</div>;
<div>{answer(expr)}</div>;
#terminal =+ element;
LineEditor.clear();
Dom.scroll_to_bottom(Dom.select_window());
Expand Down

0 comments on commit 1f171c1

Please sign in to comment.