UNPKG

1.43 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3class ParserErrors {
4 constructor() {
5 this._errors = new Map();
6 this.getErrors = (type) => {
7 if (type) {
8 if (!this._errors.has(type)) {
9 this._errors.set(type, []);
10 }
11 return this._errors.get(type);
12 }
13 else {
14 return this.allErrors;
15 }
16 };
17 this.clearErrors = (type) => {
18 if (type) {
19 this._errors.set(type, []);
20 }
21 else {
22 this._errors.clear();
23 }
24 };
25 this.push = (type, message) => {
26 const errs = this.getErrors(type);
27 errs.push(message);
28 this._errors.set(type, errs);
29 };
30 }
31 get commandErrors() {
32 return this.getErrors('command');
33 }
34 get argumentErrors() {
35 return this.getErrors('argument');
36 }
37 get optionErrors() {
38 return this.getErrors('option');
39 }
40 get allErrors() {
41 return [...this.commandErrors, ...this.argumentErrors, ...this.optionErrors];
42 }
43 get hasErrors() {
44 return this.allErrors.length > 0;
45 }
46 get hasNonArgOrOptionErrors() {
47 return this.commandErrors.length > 0;
48 }
49}
50exports.ParserErrors = ParserErrors;
51//# sourceMappingURL=ParserErrors.js.map
\No newline at end of file