2011-04-25 07:26:25 -04: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
|
2011-05-27 12:16:09 -04:00
|
|
|
attr_accessor :captures
|
|
|
|
attr_accessor :eval_string
|
|
|
|
attr_accessor :arg_string
|
2011-04-25 07:26:25 -04:00
|
|
|
attr_accessor :opts
|
2011-04-25 17:13:36 -04:00
|
|
|
attr_accessor :command_set
|
2011-04-29 12:14:48 -04:00
|
|
|
attr_accessor :command_processor
|
2011-04-25 17:13:36 -04:00
|
|
|
|
2011-07-27 07:06:09 -04:00
|
|
|
# Run a command from another command.
|
|
|
|
# @param [String] command_string The string that invokes the command
|
|
|
|
# @param [Array] args Further arguments to pass to the command
|
|
|
|
# @example
|
|
|
|
# run "show-input"
|
|
|
|
# @example
|
|
|
|
# run ".ls"
|
|
|
|
# @example
|
|
|
|
# run "amend-line", "5", 'puts "hello world"'
|
2011-05-29 11:36:31 -04:00
|
|
|
def run(command_string, *args)
|
|
|
|
complete_string = "#{command_string} #{args.join(" ")}"
|
|
|
|
command_processor.process_commands(complete_string, eval_string, target)
|
2011-04-25 17:13:36 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def commands
|
|
|
|
command_set.commands
|
|
|
|
end
|
2011-04-25 07:26:25 -04:00
|
|
|
|
2011-05-06 13:28:12 -04:00
|
|
|
def text
|
2011-05-08 13:38:14 -04:00
|
|
|
Pry::Helpers::Text
|
2011-05-06 13:28:12 -04:00
|
|
|
end
|
|
|
|
|
2011-04-25 16:58:06 -04:00
|
|
|
include Pry::Helpers::BaseHelpers
|
|
|
|
include Pry::Helpers::CommandHelpers
|
2011-04-25 07:26:25 -04:00
|
|
|
end
|
|
|
|
end
|