Skip to content

Commit

Permalink
document ops, op example
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed May 13, 2013
1 parent 48b1eb9 commit a6381e6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions example/op.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var parse = require('../').parse;
var xs = parse('beep || boop > /byte');
console.dir(xs);
27 changes: 27 additions & 0 deletions readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ output
[ 'beep', '--boop=/home/robot' ]
```

## parsing shell operators

``` js
var parse = require('shell-quote').parse;
var xs = parse('beep || boop > /byte');
console.dir(xs);
```

output:

```
[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]
```

# methods

``` js
Expand All @@ -67,6 +81,19 @@ Return an array of arguments from the quoted string `cmd`.
Interpolate embedded bash-style `$VARNAME` and `${VARNAME}` variables with
the `env` object which like bash will replace undefined variables with `""`.

When a bash operator is encountered, the element in the array with be an object
with an `"op"` key set to the operator string. For example:

```
'beep || boop > /byte'
```

parses as:

```
[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]
```

# install

With [npm](http://npmjs.org) do:
Expand Down

0 comments on commit a6381e6

Please sign in to comment.