Browse files

Move command line logic into module

  • Loading branch information...
1 parent 9ea2248 commit 9d3825f361d0493996bf0e18f05f11cd87a885d3 @brandonbloom committed Oct 4, 2011
Showing with 18 additions and 11 deletions.
  1. +1 −11 bin/html2coffeekup
  2. +17 −0 lib/cli.coffee
View
12 bin/html2coffeekup
@@ -3,15 +3,5 @@
path = require 'path'
fs = require 'fs'
-
-if process.argv.length < 3
- console.log "Usage: #{path.basename(__filename)} <html-file>"
- process.exit 1
-
-
lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib')
-{convert} = require "#{lib}/convert"
-
-html = fs.readFileSync process.argv[2], 'utf8'
-convert html, process.stdout, (err) ->
- console.error err if err
+require("#{lib}/cli").main()
View
17 lib/cli.coffee
@@ -0,0 +1,17 @@
+#!/usr/bin/env coffee
+
+path = require 'path'
+fs = require 'fs'
+{convert} = require './convert'
+
+
+exports.main = ->
+ [interpreter, script, args...] = process.argv
+
+ if args.length == 0
+ console.log "Usage: #{path.basename(script)} <html-file>"
+ process.exit 1
+
+ html = fs.readFileSync args[0], 'utf8'
+ convert html, process.stdout, (err) ->
+ console.error err if err

0 comments on commit 9d3825f

Please sign in to comment.