Permalink
Browse files

Added --format, -f opt to ohl2html

  • Loading branch information...
1 parent ca577b8 commit a885e81feb508ca249f9a1b80d30f345d8708e7f @arikon arikon committed Aug 14, 2011
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/2html.js
View
@@ -17,6 +17,7 @@ exports.main = function() {
'Options:',
' -i, --input : pecifies filename to read the input source, if omit use STDIN',
' -o, --output : specifies filename to write the output, if omit use STDOUT',
+ ' -f, --format : specifies code format, valid values are "js" and "xml", if omit use "js"',
' -h, --help : Output help information'
].join('\n'));
process.exit(1);
@@ -29,6 +30,14 @@ exports.main = function() {
case '--output':
options.output = args.shift();
break;
+ case '-f':
+ case '--format':
+ options.format = args.shift();
+ if (['javascript', 'js', 'xml'].indexOf(options.format) == -1) {
+ sys.error('Wrong format "' + options.format + '" specified, must be one of "js" or "xml"');
+ process.exit(1);
+ }
+ break;
}
}
@@ -50,7 +59,7 @@ exports.main = function() {
try {
var ohl = require('./ometa-highlighter'),
result = ohl.OmetaHighlighterToHtml.match(
- ohl.OmetaHighlighter.matchAll(input, 'js'), // TODO: use format from options
+ ohl.OmetaHighlighter.matchAll(input, options.format || 'js'),
'topLevel'
);
options.output ?

0 comments on commit a885e81

Please sign in to comment.