2011-04-25 11:26:25 +00:00
|
|
|
class Pry
|
|
|
|
# Command contexts are the objects runing each command.
|
|
|
|
# Helper modules can be mixed into this class.
|
|
|
|
class CommandContext
|
|
|
|
attr_accessor :output
|
|
|
|
attr_accessor :target
|
|
|
|
attr_accessor :opts
|
2011-04-25 21:13:36 +00:00
|
|
|
attr_accessor :command_set
|
|
|
|
|
|
|
|
def run(name, *args)
|
2011-04-26 21:44:49 +00:00
|
|
|
if name.start_with? "."
|
|
|
|
cmd = name[1..-1]
|
|
|
|
|
|
|
|
unless system("#{cmd} #{args.join(' ')}")
|
|
|
|
output.puts "Error: there was a problem executing system command: #{cmd}"
|
|
|
|
end
|
|
|
|
else
|
|
|
|
command_set.run_command(self, name, *args)
|
|
|
|
end
|
2011-04-25 21:13:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def commands
|
|
|
|
command_set.commands
|
|
|
|
end
|
2011-04-25 11:26:25 +00:00
|
|
|
|
2011-04-25 20:58:06 +00:00
|
|
|
include Pry::Helpers::BaseHelpers
|
|
|
|
include Pry::Helpers::CommandHelpers
|
2011-04-25 11:26:25 +00:00
|
|
|
end
|
|
|
|
end
|