egirlskey/src/parse-opt.ts

18 lines
399 B
TypeScript
Raw Normal View History

2018-03-29 05:59:06 +00:00
import * as nopt from 'nopt';
2018-03-28 16:20:40 +00:00
2018-06-18 05:28:43 +00:00
export default (vector: any, index: any) => {
2018-03-28 16:20:40 +00:00
const parsed = nopt({
'only-processor': Boolean,
'only-server': Boolean
}, {
p: ['--only-processor'],
s: ['--only-server']
}, vector, index);
if (parsed['only-processor'] && parsed['only-server']) {
throw 'only-processor option and only-server option cannot be set at the same time';
}
return parsed;
};