Skip to content

Commit

Permalink
Add help command. Helps #14
Browse files Browse the repository at this point in the history
  • Loading branch information
toivoh committed Dec 9, 2012
1 parent 46896d2 commit 00c5965
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
34 changes: 23 additions & 11 deletions src/UI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ module UI
using Base, Meta, AST, Eval, Flow
export trap

const helptext =
"Commands:
--------
h: show this help text
s: step into
n: step over any enclosed scope
o: step out from the current scope
c: continue to next breakpoint
q: quit"


instrument(ex) = Flow.instrument(trap, ex)

state = DBState()
Expand All @@ -21,17 +32,18 @@ function trap(node, scope::Scope)
elseif cmd == "o"; stepout!(state, node, scope); break
elseif cmd == "c"; continue!(state); break
elseif cmd == "q"; continue!(state); error("interrupted")
end

try
ex0, nc = parse(cmd)
ex = interpolate({:st => state, :n => node, :s => scope,
:bp => state.breakpoints,
:pre => state.grafts}, ex0)
r = debug_eval(scope, ex)
if !is(r, nothing); show(r); println(); end
catch e
println(e)
elseif cmd == "h"; println(helptext)
else
try
ex0, nc = parse(cmd)
ex = interpolate({:st => state, :n => node, :s => scope,
:bp => state.breakpoints,
:pre => state.grafts}, ex0)
r = debug_eval(scope, ex)
if !is(r, nothing); show(r); println(); end
catch e
println(e)
end
end
end
end
Expand Down
8 changes: 1 addition & 7 deletions test/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ include(find_in_path("Debug.jl"))
module TestInteractive
using Base, Debug

println("Commands:")
println("--------")
println("s: step into")
println("n: step over any enclosed scope")
println("o: step out from the current scope")
println("c: continue to next breakpoint")
println("q: quit")
println(Debug.UI.helptext)
println()
println("Type an expression to evaluate it in the current scope.")

Expand Down

0 comments on commit 00c5965

Please sign in to comment.