Skip to content

Commit

Permalink
fixed doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jbilcke committed Mar 28, 2012
1 parent 03001cc commit 2f7d4f7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
31 changes: 23 additions & 8 deletions README.md
Expand Up @@ -70,27 +70,42 @@
For the moment the syntax is minimal, and code is documentation. You are warned.

``` coffeescript
cli =
#!/usr/bin/env coffee

# use
cmdr = require 'cmdr'

# think
api =
foo:
desc: "create a new bar"
func: (name="") ->
if name.length is 0
error "you need to provide a bar name"
console.log "you need to provide a bar name"
process.exit 1
else
log "creating bar #{name}"
console.log "creating bar #{name}"
process.exit 0

pi:
desc: "don't use me"
func: ->
3.1415
console.log 3.1415

# profit
cmdr api

cmdr cli
```

### API
Now you should be able to use your program in command-line, to call the functions:

#### Human-readable
``` bash
$ myprogram foo
you need to provide a bar name

$ myprogram foo bara
creating bar bara

NO.
$ myprogram pi
3.1415
```
4 changes: 2 additions & 2 deletions lib/cmdr.js
@@ -1,5 +1,5 @@
(function() {
var cmdr, error, log, main, _ref;
var error, log, main, _ref;

_ref = require("daizoru-toolbox"), log = _ref.log, error = _ref.error;

Expand Down Expand Up @@ -38,7 +38,7 @@
}
};

exports.cmdr = cmdr = function(model) {
module.exports = function(model) {
return main(model, process.argv.slice(2));
};

Expand Down
2 changes: 1 addition & 1 deletion src/cmdr.coffee
Expand Up @@ -28,5 +28,5 @@ main = (model, a=[]) ->
error "never heard about #{msg}"
return

exports.cmdr = cmdr = (model) ->
module.exports = (model) ->
main model, process.argv[2..]

0 comments on commit 2f7d4f7

Please sign in to comment.