Skip to content

Commit

Permalink
Updated README and removed console log
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminlykins committed Sep 6, 2016
1 parent dcc49bb commit bc2a300
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ Simple way to serialize JavaScript objects from command line arguments
## Synopsis
You can make JSON style objects directly from command line arguments using the simple notation
```
$ node add-contact.js person -firstname --john -lastname --smith
$ node add-contact.js person -firstname --john -lastname --smith -age --30
```
Would serialize to
```
{
person: {
firstname: 'john',
lastname: 'smith'
lastname: 'smith',
age: 30
}
}
```
## Usage
```
//$ exampleProgram person -firstname --john -lastname --smith
//$ exampleProgram person -firstname --john -lastname --smith -age --30
var cla = require('command-line-arguments');
Expand All @@ -44,7 +45,7 @@ food = cla.getCommandLineArguments();
// food =
// {
// name: 'hotdog',
// calories: '400',
// calories: 400,
// 'primary-ingredients': [ 'bun', 'dog', 'mustard', 'ketchup' ]
// };
```
Expand Down
4 changes: 1 addition & 3 deletions lib/command-line-arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ function isLastLevel(arr){

function getSubLevels(arr){
//console.log("getSubLevels(" + arr + ")");

for(var i = 1; i < arr.length; i++){
if(arr[i].substring(0,1) != '-'){
//console.log("->" + arr.slice(1, i));
if(arr.slice(1, i).length === 1){
console.log(arr[1]);
if(!isNaN(arr[1])){
return parseInt(arr[i]);
}
Expand Down Expand Up @@ -108,7 +106,7 @@ function recurse(arr){

function getGetCommandLineArguments(params){
if(!params){
console.log("null");
//console.log("null");
}
return recurse(params);
}
Expand Down

0 comments on commit bc2a300

Please sign in to comment.