lib/ronin/ui/shell.rb in ronin-0.2.4 vs lib/ronin/ui/shell.rb in ronin-0.3.0
- old
+ new
@@ -1,9 +1,7 @@
#
-#--
-# Ronin - A Ruby platform designed for information security and data
-# exploration tasks.
+# Ronin - A Ruby platform for exploit development and security research.
#
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,11 +14,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#++
#
module Ronin
module Shell
@@ -29,15 +26,29 @@
#
# Creates and starts a new Shell object with the specified _options_.
# If a _block_ is given, it will be passed every command.
#
- # _options_ may contain the following keys:
- # <tt>:name</tt>:: Name of the shell.
- # <tt>:prompt</tt>:: Prompt to use for the shell, defaults to
- # +DEFAULT_PROMPT+.
+ # @param [Hash] options
+ # Additional options.
#
+ # @option options [String] :name ('')
+ # The shell-name to use before the prompt.
+ #
+ # @option options [String] :prompt (DEFAULT_PROMPT)
+ # The prompt to use for the shell.
+ #
+ # @yield [shell, line]
+ # The block that will be passed every command entered.
+ #
+ # @yieldparam [Shell] shell
+ # The shell to use for output.
+ #
+ # @yieldparam [String] line
+ # The command entered into the shell.
+ #
+ # @example
# Shell.start(:prompt => '$') { |shell,line| system(line) }
#
def Shell.start(options={},&block)
name = (options[:name] || '')
prompt = (options[:prompt] || DEFAULT_PROMPT)
@@ -64,31 +75,46 @@
history_rollback.times { Readline::HISTORY.pop }
return nil
end
#
- # Equivalent to <tt>STDOUT.putc(char)</tt>.
+ # Print a character to the shell.
#
+ # @param [String] char
+ # The character to print.
+ #
def Shell.putc(char)
STDOUT.putc(char)
end
#
- # Equivalent to <tt>STDOUT.print(string)</tt>.
+ # Print a String to the shell.
#
+ # @param [String] string
+ # The String to print.
+ #
def Shell.print(string)
STDOUT.print(string)
end
#
- # Equivalent to <tt>STDOUT.puts(string)</tt>.
+ # Print a String and a new-line character to the shell.
#
+ # @param [String] string
+ # The String to print.
+ #
def Shell.puts(string)
STDOUT.puts(string)
end
#
- # Equivalent to <tt>STDOUT.printf(string,*objects)</tt>.
+ # Render the format-string and print the result to the shell.
+ #
+ # @param [String] string
+ # The format-string to render.
+ #
+ # @param [Array] objects
+ # Additional objects to use in the format-string.
#
def Shell.printf(string,*objects)
STDOUT.printf(string,*objects)
end