lib/yard/cli/command_parser.rb in yard-0.9.5 vs lib/yard/cli/command_parser.rb in yard-0.9.6
- old
+ new
@@ -1,5 +1,6 @@
+# frozen_string_literal: true
module YARD
module CLI
# This class parses a command name out of the +yard+ CLI command and calls
# that command in the form:
#
@@ -59,17 +60,17 @@
# Runs the {Command} object matching the command name of the first
# argument.
# @return [void]
def run(*args)
unless args == ['--help']
- if args.size == 0 || args.first =~ /^-/
+ if args.empty? || args.first =~ /^-/
command_name = self.class.default_command
else
command_name = args.first.to_sym
args.shift
end
- if commands.has_key?(command_name)
+ if commands.key?(command_name)
return commands[command_name].run(*args)
end
end
list_commands
end
@@ -80,10 +81,10 @@
def list_commands
log.puts "Usage: yard <command> [options]"
log.puts
log.puts "Commands:"
- commands.keys.sort_by {|k| k.to_s }.each do |command_name|
+ commands.keys.sort_by(&:to_s).each do |command_name|
command = commands[command_name].new
log.puts "%-8s %s" % [command_name, command.description]
end
end
end