lib/inch/cli/command_parser.rb in inch-0.4.6 vs lib/inch/cli/command_parser.rb in inch-0.4.7

- old
+ new

@@ -1,8 +1,9 @@ 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] # @@ -53,11 +54,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 @@ -70,13 +71,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 " %-8s %s" % [command_name, command.description] + ui.trace format(" %-8s %s", command_name, command.description) end end # Runs the {Command} object matching the command name of the first # argument. @@ -85,10 +86,10 @@ if args.empty? command_name = self.class.default_command else possible_command_name = args.first.to_sym - if commands.has_key?(possible_command_name) + if commands.key?(possible_command_name) command_name = possible_command_name args.shift else command_name = self.class.default_command end