Class: Frepl::ReplCommand
Constant Summary
collapse
- COMMANDS =
{
'run' => {
info: 'Run the current set of Fortran code',
l: lambda { |file| file.run },
},
'toggle_debug' => {
info: 'Toggle debug mode on/off',
l: lambda { |file| Frepl.debug = !Frepl.debug },
},
'help' => {
info: 'View this hopefully helpful help',
l: lambda do |file|
puts "Available Frepl commands:\n"
COMMANDS.each do |k, v|
puts "f:#{k} -- #{v[:info]}"
end
end
},
'z' => {
info: 'Undo last statement',
l: lambda do |file|
file.undo_last!
end
}
}
Instance Attribute Summary
#line
Instance Method Summary
collapse
#incomplete?, #initialize, #output
Methods inherited from Statement
#incomplete?, #output
Instance Method Details
#accept(visitor) ⇒ Object
29
30
31
|
# File 'lib/frepl/statements/repl_command.rb', line 29
def accept(visitor)
visitor.visit_repl_command(self)
end
|
#cmd ⇒ Object
42
43
44
|
# File 'lib/frepl/statements/repl_command.rb', line 42
def cmd
@cmd ||= line.match(/f:(.+)/)[1]
end
|
#run(file) ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/frepl/statements/repl_command.rb', line 33
def run(file)
Frepl.log("running: #{cmd}")
if COMMANDS.key?(cmd)
COMMANDS[cmd][:l].call(file)
else
puts "Unknown command: `#{cmd}`. Type `f:help` for list of commands."
end
end
|