Skip to content

Commit

Permalink
use antimatter for command line docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Escalante committed Mar 6, 2014
1 parent 224291f commit 092b242
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 57 deletions.
76 changes: 20 additions & 56 deletions lib/commands/help.coffee
Original file line number Diff line number Diff line change
@@ -1,73 +1,37 @@
require('colors')
antimatter = require 'anti-matter'

exports.execute = ->
console.log(
"\n" +
"Roots Usage\n".red.bold +
"-----------\n".bold +

document_option(
antimatter
title: 'Roots Usage'
options: { log: true, width: 65 }
commands: [{
name: 'new'
required: ['name']
optional: ['dir', '--template-name']
description: 'Creates a new roots project called [name] in [dir]. If [dir] is not provided, project is created in the current directory. The [--template-name] option lets you choose to initialize with an installed template.'
) +

document_option(
}, {
name: 'compile'
optional: ['--no-compress']
description: 'Compiles the roots project. Optional flag will not compress or minify files.'
) +

document_option(
description: 'Compiles the roots project. Optional flag will not compress or minify files.'
}, {
name: 'watch'
optional: ['dir', '--no-open', '--no-livereload']
description: 'Watches the given [dir] or current directory and recompiles every time changes are made.'
) +

document_option(
description: 'Watches the given [dir] or current directory and recompiles every time changes are made.'
}, {
name: 'deploy'
required: ['deployer']
optional: ['file/dir']
description: 'Deploys the given [file/dir] or by default the output folder via the given [deployer]. See http://ship.io for deployers.'
) +

document_option(
description: 'Deploys the given [file/dir] or by default the output folder via the given [deployer]. See http://ship.io for deployers.'
}, {
name: 'clean'
description: 'Removes the output folder.'
) +

document_option(
description: 'Removes the output folder.'
}, {
name: 'version'
description: 'Outputs the currently installed version of roots.'
) +

document_option(
description: 'Outputs the currently installed version of roots.'
}, {
name: 'template'
description: 'Manage roots templates. `roots template` for help.'
) +

document_option(
description: 'Manage roots templates. `roots template` for help.'
}, {
name: 'pkg'
description: 'Utilize a roots-integrated package manager. `roots pkg` for help.'
) +

"\nCheck out https://roots.cx for more docs and tutorials!\n".green
)

wordwrap = (str, width, brk, cut) ->
brk = brk || '\n'
width = width || 75
cut = cut || false
if !str then return str
regex = '.{1,' +width+ '}(\\s|$)' + (if cut then '|.{' +width+ '}|.+$' else '|\\S+?(\\s|$)')
return str.match( RegExp(regex, 'g') ).join(brk)

document_option = (conf) ->
res = "\n* ".red
res += "#{conf.name.bold} "
res += "#{arg.underline} ".grey for arg in conf.required if conf.required
res += "[#{arg}] ".grey for arg in conf.optional if conf.optional
res += "\n"
res += "#{wordwrap(conf.description, 59, '\n')}"
res += "\n"
description: 'Utilize a roots-integrated package manager. `roots pkg` for help.'
}]
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"infestor": "0.2.x",
"faye-websocket": "0.7.x",
"graceful-fs": "2.x",
"vinyl": "0.2.x"
"vinyl": "0.2.x",
"anti-matter": "0.0.1"
},
"devDependencies": {
"mocha": "*",
Expand Down

0 comments on commit 092b242

Please sign in to comment.