From a5c2dec02199b0df0a7d6694e33563cb38d9356c Mon Sep 17 00:00:00 2001 From: John Mair Date: Wed, 13 Apr 2011 23:49:45 +1200 Subject: [PATCH] added highlighting to disabled commands in GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu) These shell commands are defined internally. Type `help' to see this list. Type `help name' to find out more about the function `name'. Use `info bash' to find out more about the shell in general. Use `man -k' or `info' to find out more about commands not in this list. A star (*) next to a name means that the command is disabled. job_spec [&] history [-c] [-d offset] [n] or history -anrw [filename] o> (( expression )) if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS> . filename [arguments] jobs [-lnprs] [jobspec ...] or jobs -x command [args] : kill [-s sigspec | -n signum | -sigspec] pid | jobspec ...> [ arg... ] let arg [arg ...] [[ expression ]] local [option] name[=value] ... alias [-p] [name[=value] ... ] logout [n] bg [job_spec ...] mapfile [-n count] [-O origin] [-s count] [-t] [-u fd] [-C> bind [-lpvsPVS] [-m keymap] [-f filename] [-q name] [-u nam> popd [-n] [+N | -N] break [n] printf [-v var] format [arguments] builtin [shell-builtin [arg ...]] pushd [-n] [+N | -N | dir] caller [expr] pwd [-LP] case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]... esac read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-> cd [-L|-P] [dir] readarray [-n count] [-O origin] [-s count] [-t] [-u fd] [> command [-pVv] command [arg ...] readonly [-af] [name[=value] ...] or readonly -p compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpa> return [n] complete [-abcdefgjksuv] [-pr] [-DE] [-o option] [-A action> select NAME [in WORDS ... ;] do COMMANDS; done compopt [-o|+o option] [-DE] [name ...] set [--abefhkmnptuvxBCHP] [-o option-name] [arg ...] continue [n] shift [n] coproc [NAME] command [redirections] shopt [-pqsu] [-o] [optname ...] declare [-aAfFilrtux] [-p] [name[=value] ...] source filename [arguments] dirs [-clpv] [+N] [-N] suspend [-f] disown [-h] [-ar] [jobspec ...] test [expr] echo [-neE] [arg ...] time [-p] pipeline enable [-a] [-dnps] [-f filename] [name ...] times eval [arg ...] trap [-lp] [[arg] signal_spec ...] exec [-cl] [-a name] [command [arguments ...]] [redirection> true exit [n] type [-afptP] name [name ...] export [-fn] [name[=value] ...] or export -p typeset [-aAfFilrtux] [-p] name[=value] ... false ulimit [-SHacdefilmnpqrstuvx] [limit] fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [com> umask [-p] [-S] [mode] fg [job_spec] unalias [-a] name [name ...] for NAME [in WORDS ... ] ; do COMMANDS; done unset [-f] [-v] [name ...] for (( exp1; exp2; exp3 )); do COMMANDS; done until COMMANDS; do COMMANDS; done function name { COMMANDS ; } or name () { COMMANDS ; } variables - Names and meanings of some shell variables getopts optstring name [arg] wait [id] hash [-lr] [-p pathname] [-dt] [name ...] while COMMANDS; do COMMANDS; done help [-dms] [pattern ...] { COMMANDS ; } --- README.markdown | 18 ++++++++++++++++-- lib/pry/command_base.rb | 6 +++++- lib/pry/command_processor.rb | 4 +++- lib/pry/commands.rb | 3 ++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/README.markdown b/README.markdown index 15d7864c..d2c1b942 100644 --- a/README.markdown +++ b/README.markdown @@ -3,9 +3,23 @@ Pry (C) John Mair (banisterfiend) 2011 -_attach an irb-like session to any object at runtime_ +_Ruby voyeurism_ -Pry is a simple Ruby REPL (Read-Eval-Print-Loop) that specializes in the interactive +Pry is a powerful alternative to the standard IRB shell for Ruby. It is +written from scratch to provide a number of advanced features, some of +these include: + +* Runtime invocation +* Syntax highlighting +* Command shell integration +* Source code browsing (including core C source with the pry-doc gem) +* Documentation browsing +* Exotic object support (BasicObject instances, IClasses, ...) +* A Powerful and flexible command system +* Gisting ability +* Many convenience commands + +Pry is a Ruby REPL (Read-Eval-Print-Loop) that specializes in the interactive manipulation of objects during the running of a program. In some sense it is the opposite of IRB in that you bring a REPL diff --git a/lib/pry/command_base.rb b/lib/pry/command_base.rb index 9262da90..c7565d3a 100644 --- a/lib/pry/command_base.rb +++ b/lib/pry/command_base.rb @@ -146,7 +146,11 @@ class Pry output.puts help_text = heading("Command List:") + "\n" command_info.each do |k, data| - help_text << ("#{k}".ljust(18) + data[:description] + "\n") if !data[:description].empty? + if !data[:stub_info] + help_text << ("#{k}".ljust(18) + data[:description] + "\n") if !data[:description].empty? + else + help_text << (bold("#{k}".ljust(18) + data[:description] + "\n")) if !data[:description].empty? + end end stagger_output(help_text) else diff --git a/lib/pry/command_processor.rb b/lib/pry/command_processor.rb index 22fa8604..c5819a0c 100644 --- a/lib/pry/command_processor.rb +++ b/lib/pry/command_processor.rb @@ -70,7 +70,8 @@ class Pry system(cmd) end - val.clear + # Tick, tock, im getting rid of this shit soon. + val.replace("") end # Determine whether a Pry command was matched and return command data @@ -154,6 +155,7 @@ class Pry ret_val = commands.instance_exec(*args_with_corrected_arity, &action) end + # Tick, tock, im getting rid of this shit soon. options[:val].clear ret_val diff --git a/lib/pry/commands.rb b/lib/pry/commands.rb index d900d95e..a4935727 100644 --- a/lib/pry/commands.rb +++ b/lib/pry/commands.rb @@ -84,7 +84,8 @@ e.g: stat hello_method output.puts make_header(meth, code_type, code) output.puts bold("Method Name: ") + meth_name output.puts bold("Method Language: ") + code_type.to_s.capitalize - output.puts bold("Method type: ") + (meth.is_a?(Method) ? "Bound" : "Unbound") + output.puts bold("Method Type: ") + (meth.is_a?(Method) ? "Bound" : "Unbound") + output.puts bold("Method Arity: ") + meth.arity.to_s output.puts bold("Comment length: ") + (doc.empty? ? 'No comment.' : (doc.lines.count.to_s + ' lines.')) end