diff options
author | murphy <murphy@rubychan.de> | 2006-05-11 23:32:49 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2006-05-11 23:32:49 +0000 |
commit | b4a4f4148a1627aed63c602f43bd4b5ef5093c4f (patch) | |
tree | 9709696cde081419c118215ea31690e1c0bb6dfd /bin/coderay | |
parent | f5f50a14c523327a28b39eeb0223261434d6d9f7 (diff) | |
download | coderay-b4a4f4148a1627aed63c602f43bd4b5ef5093c4f.tar.gz |
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
Diffstat (limited to 'bin/coderay')
-rw-r--r-- | bin/coderay | 21 |
1 files changed, 11 insertions, 10 deletions
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 -<lang> [-<format>] < file > output
+ coderay file [-<format>]
+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
|