Skip to content

Commit

Permalink
executable: only the first arg can be subcommand, avoid map lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
korny committed Sep 8, 2011
1 parent c03fbba commit b91d633
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bin/coderay
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'coderay'

$options, args = ARGV.partition { |arg| arg[/^-[hv]$|--\w+/] }
subcommand = args.detect { |arg| arg[/^\w/] }
subcommand = args.first if /^\w/ === args.first
subcommand = nil if subcommand && File.exist?(subcommand)
args.delete subcommand

Expand Down Expand Up @@ -105,7 +105,7 @@ when 'highlight', nil
if output_file
output_filetype ||= CodeRay::FileType[output_file]
else
output_filetype ||= :term
output_filetype ||= :terminal
end

output_filetype = :page if output_filetype.to_s == 'html'
Expand Down

0 comments on commit b91d633

Please sign in to comment.