Skip to content

Commit

Permalink
add encoding option
Browse files Browse the repository at this point in the history
  • Loading branch information
timb committed Apr 22, 2015
1 parent a0a92a3 commit c0cdc78
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions bin/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ Draw irc formatted text to a terminal
Options:
-p palette
Use a different palette (default: mirc)
-e encoding
Load file with a different encoding like ascii or binary (default: utf8)
8 changes: 5 additions & 3 deletions bin/irc2ansi.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ var readline = require('readline');
var colorcode_to_ansi = require('../src/to_ansi');

var argv = require('minimist')(process.argv.slice(2), {
alias: {p: "palette", h: "help", v: "version"},
alias: {p: "palette", h: "help", v: "version", e: "encoding"},
boolean: ['h', 'v']
});

// console.log(argv)

var opts = {};

if ("p" in argv) opts.palette = argv.p;

var encoding = "e" in argv ? argv.e : "utf8";

if (argv.v) {
return console.log(require('../package.json').version);
}
Expand All @@ -30,7 +31,7 @@ if ((argv.h) ||

// passed a filename
if (argv._.length > 0){
fs.readFile(argv._[0], 'utf8', function(err, data){
fs.readFile(argv._[0], encoding, function(err, data){
if (err) return console.log(err);
console.log(colorcode_to_ansi(data, opts))
});
Expand All @@ -39,6 +40,7 @@ if (argv._.length > 0){

// piped in input
if (argv._.length === 0){
process.stdin.setEncoding(encoding);
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "irc2ansi",
"version": "0.1.1",
"version": "0.1.2",
"description": "draw irc formatted text to a terminal",
"author": "@timb",
"license": "WTFPL",
Expand Down

0 comments on commit c0cdc78

Please sign in to comment.