lib/inch/cli/command_parser.rb in inch-0.4.10 vs lib/inch/cli/command_parser.rb in inch-0.5.0.rc1
- old
+ new
@@ -1,9 +1,8 @@
module Inch
module CLI
- # CommandParser parses a command-line arguments to decide which Command to
- # run.
+ # CommandParser parses a command-line arguments to decide which Command to run.
#
# The basic form translates this shell command
#
# $ inch command_name [options]
#
@@ -54,11 +53,11 @@
# Runs the {Command} object matching the command name of the first
# argument.
# @return [Command::Base]
def run(*args)
- if ["--help", "-h"].include?(args.join)
+ if ['--help', '-h'].include?(args.join)
list_commands
else
run_command(*args)
end
end
@@ -71,13 +70,13 @@
def list_commands
ui.trace "Usage: inch <command> [options]"
ui.trace
ui.trace "Commands:"
- commands.keys.sort_by { |k| k.to_s }.each do |command_name|
+ commands.keys.sort_by {|k| k.to_s }.each do |command_name|
command = commands[command_name].new
- ui.trace format(" %-8s %s", command_name, command.description)
+ ui.trace " %-8s %s" % [command_name, command.description]
end
end
# Runs the {Command} object matching the command name of the first
# argument.
@@ -86,10 +85,10 @@
if args.empty?
command_name = self.class.default_command
else
possible_command_name = args.first.to_sym
- if commands.key?(possible_command_name)
+ if commands.has_key?(possible_command_name)
command_name = possible_command_name
args.shift
else
command_name = self.class.default_command
end