Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial readme and license

  • Loading branch information...
commit 591e078004721698334023c58aa5d2f7715b5626 1 parent f4d3242
@felixge authored
Showing with 87 additions and 0 deletions.
  1. +19 −0 License
  2. +68 −0 Readme.md
View
19 License
@@ -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.
View
68 Readme.md
@@ -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.
Please sign in to comment.
Something went wrong with that request. Please try again.