Skip to content

Commit

Permalink
feat: add identifying of non-flag arguments
Browse files Browse the repository at this point in the history
- Add new attribute isFlag in argument Object
- Add identifying of non-flag arguments

Closes #26
  • Loading branch information
ifedchankau authored and itekaf committed Jul 16, 2018
1 parent 5ffeb9c commit 4853335
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const parseOption = (option) => {
let argument = {
shortName: null,
longName: null,
isFlag: true,
defaultValue: false,
description: null
};
Expand All @@ -66,6 +67,9 @@ const setArgument = (section, argument) => {
case "-":
argument.shortName = arg;
break;
default:
argument.isFlag = false;
break;
}
});
};
Expand All @@ -74,7 +78,10 @@ const setDescription = (section, argument) => {
argument.description = section;
//TODO: add other patterns for default value parsing
const defaultValues = section.match(/\[default: (.*?)\]/i);
argument.defaultValue = defaultValues ? defaultValues[1] : "";
if (defaultValues) {
argument.defaultValue = defaultValues[1];
argument.isFlag = false;
}
};

const RemoveExtraCharacters = (args) => {
Expand Down
2 changes: 1 addition & 1 deletion src/templatizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const templatizer = (options) => {
switch (argumentName){
//TODO: arguments with prefix linterhub:
default:
optionSchema.id = option.longName;
optionSchema.id = (!option.isFlag ? "args:" : "") + option.longName;
//TODO: argument types
optionSchema.type = "string";
optionSchema.description = option.description;
Expand Down

0 comments on commit 4853335

Please sign in to comment.