Skip to content

Commit

Permalink
feat: add parseWhole property to config
Browse files Browse the repository at this point in the history
Added parseWhole property to config

Closes #79
  • Loading branch information
ifedchankau authored and itekaf committed Jul 31, 2018
1 parent befe888 commit a5caec4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const handle = (help, config) => {
if (data.length > 0) {
data.forEach((object) =>
contextSection.func(object, context, argumentTemplate));
} else if (configSection.parseWhole) {
contextSection.func(help, context, argumentTemplate);
} else if (contextSection.required) {
throw new Error(`Required section ${sectionName} not found`);
}
Expand Down
11 changes: 7 additions & 4 deletions src/template/configDefault.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
":",
"\n",
":\n"
]
],
"parseWhole": true
},
"usage": {
"names": [
Expand All @@ -18,17 +19,19 @@
":",
"\n",
":\n"
]
],
"parseWhole": false
},
"examples": {
"names": [
"Examples:"
"Examples"
],
"postfix": [
":",
"\n",
":\n"
]
],
"parseWhole": false
}
},
"delimiter": "="
Expand Down
5 changes: 5 additions & 0 deletions src/template/configSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
"$ref": "#/definitions/default:array"
}
]
},
"parseWhole": {
"title": "Parse whole help",
"description": "Parsing whole help if sections with names wasn't found",
"type": "boolean"
}
},
"required": [
Expand Down

0 comments on commit a5caec4

Please sign in to comment.