Skip to content

Commit

Permalink
readme with examples
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed May 18, 2012
1 parent bc27efa commit 6373c0f
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
70 changes: 70 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
shell-quote
===========

Parse and quote shell commands.

example
=======

quote
-----

``` js
var quote = require('shell-quote').quote;
var s = quote([ 'a', 'b c d', '$f', '"g"' ]);
console.log(s);
```

output

```
a 'b c d' \$f '"g"'
```

parse
-----

``` js`
var parse = require('shell-quote').parse;
var xs = parse('a "b c" \\$def \'it\\\'s great\'');
console.dir(xs);
```
output
```
[ 'a', 'b c', '\\$def', 'it\'s great' ]
```
methods
=======
``` js
var quote = require('shell-quote').quote;
var parse = require('shell-quote').parse;
```

quote(args)
-----------

Return a quoted string for the array `args` suitable for using in shell
commands.

parse(cmd)
----------

Return an array of arguments from the quoted string `cmd`.

install
=======

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

```
npm install shell-quote
```

license
=======

MIT
3 changes: 3 additions & 0 deletions example/parse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var parse = require('../').parse;
var xs = parse('a "b c" \\$def \'it\\\'s great\'');
console.dir(xs);
3 changes: 3 additions & 0 deletions example/quote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var quote = require('../').quote;
var s = quote([ 'a', 'b c d', '$f', '"g"' ]);
console.log(s);

0 comments on commit 6373c0f

Please sign in to comment.