Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
David Rodríguez de Dios committed Apr 6, 2013
1 parent 21cc44c commit 6333416
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 29 deletions.
9 changes: 9 additions & 0 deletions lib/byebug/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ class Command
SubcmdStruct = Struct.new(:name, :min, :short_help, :long_help) unless
defined?(SubcmdStruct)

def print_subcommands
cmd_name = self.class.name.chomp("Command").downcase
errmsg "#{cmd_name} must be followed by the name of a subcommand.\n"
print "List of #{cmd_name} subcommands:\n\n"
for subcmd in Subcommands do
print "#{cmd_name} #{subcmd.name} -- #{subcmd.short_help}\n"
end
end

include Columnize

# Find param in subcmds. param id downcased and can be abbreviated
Expand Down
6 changes: 1 addition & 5 deletions lib/byebug/commands/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ def regexp

def execute
if !@match[1]
errmsg "\"info\" must be followed by the name of an info command:\n"
print "List of info subcommands:\n\n"
for subcmd in Subcommands do
print "info #{subcmd.name} -- #{subcmd.short_help}\n"
end
print_subcommands
else
args = @match[1].split(/[ \t]+/)
param = args.shift
Expand Down
6 changes: 1 addition & 5 deletions lib/byebug/commands/set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ def regexp

def execute
if not @match[1]
print "\"set\" must be followed by the name of an set command:\n"
print "List of set subcommands:\n\n"
for subcmd in Subcommands do
print "set #{subcmd.name} -- #{subcmd.short_help}\n"
end
print_subcommands
else
args = @match[1].split(/[ \t]+/)
subcmd = args.shift
Expand Down
6 changes: 1 addition & 5 deletions lib/byebug/commands/show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,7 @@ def regexp

def execute
if not @match[1]
print "\"show\" must be followed by the name of an show command:\n"
print "List of show subcommands:\n\n"
for subcmd in Subcommands do
print "show #{subcmd.name} -- #{subcmd.short_help}\n"
end
print_subcommands
else
args = @match[1].split(/[ \t]+/)
param = args.shift
Expand Down
1 change: 0 additions & 1 deletion lib/byebug/processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ def at_tracing(context, file, line)
# Don't trace ourselves
return if defined?(Byebug::RDEBUG_FILE) && Byebug::RDEBUG_FILE == file

#@last_file = CommandProcessor.canonic_file(file)
file = CommandProcessor.canonic_file(file)
unless file == @last_file and line == @last_line and
Command.settings[:tracing_plus]
Expand Down
24 changes: 11 additions & 13 deletions old_doc/byebug.texi
Original file line number Diff line number Diff line change
Expand Up @@ -1530,19 +1530,17 @@ l[ist] nn-mm list given lines

@node Help for Subcommands
@subsection Help on Subcommands
A number of commands have many sub-parameters or
@emph{subcommands}. These include @code{info}, @code{set},
@code{show}, @code{enable} and @code{disable}.

When you ask for help for one of these commands, you will get help for
all of the subcommands that that command offers. Sometimes you may
want help that subcommand and to do this just follow the command with
its subcommand name. For example @code{help set annotate} will just
give help about the annotate command. Furthermore it will give longer
help than the summary information that appears when you ask for
help. You don't need to list the full subcommand name, but just enough
of the letters to make that subcommand distinct from others will
do. For example, @code{help set an} is the same as @code{help set annotate}.
A number of commands have many sub-parameters or @emph{subcommands}. These
include @code{info}, @code{set}, @code{show}, @code{enable} and @code{disable}.

When you ask for help for one of these commands, you will get help for all of
the subcommands that that command offers. Sometimes you may want help that
subcommand and to do this just follow the command with its subcommand name. For
example @code{help set annotate} will just give help about the annotate command.
Furthermore it will give longer help than the summary information that appears
when you ask for help. You don't need to list the full subcommand name, but just
enough of the letters to make that subcommand distinct from others will do. For
example, @code{help set an} is the same as @code{help set annotate}.

Some examples follow.
@example
Expand Down

0 comments on commit 6333416

Please sign in to comment.