From b4a4f4148a1627aed63c602f43bd4b5ef5093c4f Mon Sep 17 00:00:00 2001 From: murphy Date: Thu, 11 May 2006 23:32:49 +0000 Subject: new version: 0.7.1 improved bin/coderay and included it into package added gem:install task added Duo#highlight (alias for encode) fixed a Plugin bug --- bin/coderay | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'bin/coderay') diff --git a/bin/coderay b/bin/coderay index a382a84..e0a4788 100644 --- a/bin/coderay +++ b/bin/coderay @@ -1,12 +1,9 @@ -#!C:/ruby/bin/ruby - +#!/usr/bin/env ruby # CodeRay Executable # # Version: 0.1 # Author: murphy -require 'optparse' - def err msg $stderr.puts msg end @@ -18,8 +15,11 @@ begin puts <<-USAGE CodeRay #{CodeRay::Version} (http://rd.cYcnus.de/coderay) Usage: - coderay -lang [-format] < file > output - coderay file [-format] + coderay - [-] < file > output + coderay file [-] +Example: + coderay -ruby -statistic < foo.rb + coderay codegen.c # generates codegen.c.html USAGE end @@ -40,7 +40,8 @@ Usage: output_filename, output_ext = file, /#{Regexp.escape(File.extname(file))}$/ end else - raise 'No lang/file given.' + puts 'No lang/file given.' + exit 1 end if second @@ -50,14 +51,14 @@ Usage: raise 'Invalid format (must be -xxx).' end else - $stderr.puts 'No format given; setting to default (HTML)' - format = :html + $stderr.puts 'No format given; setting to default (HTML Page)' + format = :page end output = tokens.encode format out = $stdout if output_filename - output_filename.sub output_ext, CodeRay::Encoders[format]::FILE_EXTENSION + output_filename += '.' + CodeRay::Encoders[format]::FILE_EXTENSION if File.exist? output_filename err 'File %s already exists.' % output_filename exit -- cgit v1.2.1