Skip to content

Commit

Permalink
Initial readme and license
Browse files Browse the repository at this point in the history
  • Loading branch information
felixge committed Aug 22, 2011
1 parent f4d3242 commit 591e078
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
19 changes: 19 additions & 0 deletions License
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2011 Felix Geisendörfer (felix@debuggable.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
68 changes: 68 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# bash

Utilities for using bash from node.js.

## API

### bash.escape(parameter)

Escapes the given `parameter` for bash. This is done by escaping all non
alpha-numeric / dash characters with a backslash.

Example:

```javascript
> bash.escape('hello world');
// 'Hello\\ World'
```

### bash.args(options, prefix, suffix)

Takes a list of `options` and turns them into an arguments string common to
most *nix programs.

Objects are turned into arguments:

```javascript
> bash.args({a: 1, b: 2}, '--', '=');
'--a=1 --b=2'
```

Values are escaped:

```javascript
> bash.args({foo: 'hi you'}, '--', '=');
'--foo=hi\\ you'
```

Array values turn into multiple arguments:

```javascript
> bash.args({a: [1, 2]}, '--', '=');
'--a=1 --a=2'
```

`null` / `true` values turn into flags:

```javascript
> bash.args({a: true, b: null}, '--', '=');
'--a --b'
```

Alternate suffix / prefix settings:

```javascript
> bash.args({a: 1, b: 2}, '-', ' ');
'-a 1 -b 2'
```

`options` can be an array as well:

```javascript
> bash.args([{a: 1}, {a: 2, b: 3}] '-', ' ');
'-a 1 -a 2 -b 3'
```

## License

This library is released under the MIT license.

0 comments on commit 591e078

Please sign in to comment.