feat: If a required argument is not supplied, ask for it and then resolve the command listener.

Thanks to @amovah for his contributions
This commit is contained in:
Mahdi Dibaiee
2015-07-09 15:46:27 +04:30
parent 2aaed21195
commit 41ca326173
5 changed files with 162 additions and 107 deletions

View File

@ -6,6 +6,7 @@ const ESCAPABLE = '.^$*+?()[{\\|}]'.split('');
const REQUIRED = 0;
const OPTIONAL = 1;
const REST = 2;
/**
* Parses a message for arguments, based on format
@ -39,8 +40,7 @@ export default function argumentParser(format, string) {
string = string.replace(/[^\s]+/, '').trim();
format = format.replace(/[^\s]+/, '').trim();
if (!format)
return {args: {}, params: {}};
if (!format) return {args: {}, params: {}};
let indexes = [],
params = {};
@ -60,6 +60,7 @@ export default function argumentParser(format, string) {
});
format = format.replace(FORMAT_REST, (full, arg, offset) => {
indexes.push({offset, arg});
params[arg] = REST;
return getFormat(null, 'rest');
});