Browse files

green Settings

  • Loading branch information...
1 parent 0b9db62 commit 315e58f897afcffa989fb3e74d56da6c4660b33c @msuarz msuarz committed Oct 28, 2012
Showing with 46 additions and 33 deletions.
  1. +9 −3 docs/src/frank.coffee
  2. +37 −30 src/readers/settings.coffee
View
12 docs/src/frank.coffee
@@ -1,11 +1,11 @@
+_ = require 'underscore'
{ $ } = require '../../src/utils/shell'
class @Frank
'[>\$] frank @args': (args, output) ->
- output = output.replace /\r/g, ''
- out = $ 'coffee src/frank ' + args
- out.should.include output
+ $('coffee src/frank ' + args)
+ .compact().should.include output.compact()
'@defaults =': (settings) ->
settings_file = __dirname + '/../../src/settings.coffee'
@@ -14,3 +14,9 @@ class @Frank
'@settings =': (settings) ->
settings_file = __dirname + '/../settings.coffee'
Files.verify_contains settings_file, settings
+
+ String.prototype.compact = -> _
+ .compact(
+ @replace(/\r/g, '')
+ .split('\n'))
+ .join('\n')
View
67 src/readers/settings.coffee
@@ -3,44 +3,51 @@ path = require 'path'
_ = require 'underscore'
{ defaults } = require '../settings'
+argv = {}
-usage = '''
+@read = ->
+ global.settings = {}
+ read_argv()
+ merge settings, defaults
+ set_root_folder()
+ merge_user_settings()
+ merge settings, argv
-Usage: frank [docs] [options]
+###
+# Command line
+###
-Docs: [docs.root\\[docs.type]]
+read_argv = ->
+
+ usage = '''
- shortcut to set root & type properties in settings.docs
+ Usage: frank [docs] [options]
- --docs.root docs root folder [.]
- --docs.type extension of doc files [*.txt]
+ Docs: [docs.root\\[docs.type]]
-Options:
+ shortcut to set root & type properties in settings.docs
- these become settings properties
-
- -h, --help output usage information
- -r, --report <name> select report output [console]
- -o, --only <pattern> only run docs matching <pattern>'''
-
-optimist = require 'optimist'
-argv = optimist
- .usage(usage)
- .alias('h', 'help')
- .alias('r', 'report')
- .alias('o', 'only')
- .argv
-
-if argv.h?
- optimist.showHelp()
- process.exit()
+ --docs.root docs root folder [.]
+ --docs.type extension of doc files [*.txt]
-@read = ->
- global.settings = {}
- merge settings, defaults
- set_root_folder()
- merge_user_settings()
- merge settings, argv
+ Options:
+
+ these become settings properties
+
+ -h, --help output usage information
+ -r, --report <name> select report output [console]
+ -o, --only <pattern> only run docs matching <pattern>
+ '''
+
+ argv = require('optimist')
+ .alias('h', 'help')
+ .alias('r', 'report')
+ .alias('o', 'only')
+ .argv
+
+ if argv.help?
+ console.log usage
+ process.exit()
###
# Root Folder

0 comments on commit 315e58f

Please sign in to comment.