@sapphire/lexure 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +145 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.global.js +1073 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +559 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +522 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/ArgumentStream.d.ts +378 -0
- package/dist/lib/lexer/Lexer.d.ts +16 -0
- package/dist/lib/lexer/streams/ParameterStream.d.ts +11 -0
- package/dist/lib/lexer/streams/parameters/BaseParameter.d.ts +7 -0
- package/dist/lib/lexer/streams/parameters/QuotedParameter.d.ts +10 -0
- package/dist/lib/lexer/streams/parameters/WordParameter.d.ts +8 -0
- package/dist/lib/lexer/streams/raw/TokenStream.d.ts +34 -0
- package/dist/lib/parser/Parser.d.ts +10 -0
- package/dist/lib/parser/ParserResult.d.ts +14 -0
- package/dist/lib/parser/strategies/EmptyStrategy.d.ts +7 -0
- package/dist/lib/parser/strategies/IUnorderedStrategy.d.ts +14 -0
- package/dist/lib/parser/strategies/PrefixedStrategy.d.ts +10 -0
- package/package.json +67 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var __publicField = (obj, key, value) => {
|
|
23
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// src/index.ts
|
|
28
|
+
var src_exports = {};
|
|
29
|
+
__export(src_exports, {
|
|
30
|
+
ArgumentStream: () => ArgumentStream,
|
|
31
|
+
BaseParameter: () => BaseParameter,
|
|
32
|
+
EmptyStrategy: () => EmptyStrategy,
|
|
33
|
+
Lexer: () => Lexer,
|
|
34
|
+
ParameterStream: () => ParameterStream,
|
|
35
|
+
Parser: () => Parser,
|
|
36
|
+
ParserResult: () => ParserResult,
|
|
37
|
+
PrefixedStrategy: () => PrefixedStrategy,
|
|
38
|
+
QuotedParameter: () => QuotedParameter,
|
|
39
|
+
TokenStream: () => TokenStream,
|
|
40
|
+
TokenType: () => TokenType,
|
|
41
|
+
WordParameter: () => WordParameter
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(src_exports);
|
|
44
|
+
|
|
45
|
+
// src/lib/ArgumentStream.ts
|
|
46
|
+
var import_result = require("@sapphire/result");
|
|
47
|
+
var ArgumentStream = class {
|
|
48
|
+
constructor(results) {
|
|
49
|
+
__publicField(this, "results");
|
|
50
|
+
__publicField(this, "state");
|
|
51
|
+
this.results = results;
|
|
52
|
+
this.state = { used: /* @__PURE__ */ new Set(), position: 0 };
|
|
53
|
+
}
|
|
54
|
+
get finished() {
|
|
55
|
+
return this.used === this.length;
|
|
56
|
+
}
|
|
57
|
+
get length() {
|
|
58
|
+
return this.results.ordered.length;
|
|
59
|
+
}
|
|
60
|
+
get remaining() {
|
|
61
|
+
return this.length - this.used;
|
|
62
|
+
}
|
|
63
|
+
get used() {
|
|
64
|
+
return this.state.used.size;
|
|
65
|
+
}
|
|
66
|
+
single() {
|
|
67
|
+
if (this.finished)
|
|
68
|
+
return import_result.Option.none;
|
|
69
|
+
while (this.state.used.has(this.state.position)) {
|
|
70
|
+
++this.state.position;
|
|
71
|
+
}
|
|
72
|
+
this.state.used.add(this.state.position);
|
|
73
|
+
return import_result.Option.some(this.results.ordered[this.state.position++].value);
|
|
74
|
+
}
|
|
75
|
+
singleMap(predicate, useAnyways = false) {
|
|
76
|
+
if (this.finished)
|
|
77
|
+
return import_result.Option.none;
|
|
78
|
+
while (this.state.used.has(this.state.position)) {
|
|
79
|
+
++this.state.position;
|
|
80
|
+
}
|
|
81
|
+
const result = predicate(this.results.ordered[this.state.position].value);
|
|
82
|
+
if (result.isSome() || useAnyways) {
|
|
83
|
+
this.state.used.add(this.state.position);
|
|
84
|
+
++this.state.position;
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
async singleMapAsync(predicate, useAnyways = false) {
|
|
89
|
+
if (this.finished)
|
|
90
|
+
return import_result.Option.none;
|
|
91
|
+
while (this.state.used.has(this.state.position)) {
|
|
92
|
+
++this.state.position;
|
|
93
|
+
}
|
|
94
|
+
const result = await predicate(this.results.ordered[this.state.position].value);
|
|
95
|
+
if (result.isSome() || useAnyways) {
|
|
96
|
+
this.state.used.add(this.state.position);
|
|
97
|
+
++this.state.position;
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
singleParse(predicate, useAnyways = false) {
|
|
102
|
+
if (this.finished)
|
|
103
|
+
return import_result.Result.err(null);
|
|
104
|
+
while (this.state.used.has(this.state.position)) {
|
|
105
|
+
++this.state.position;
|
|
106
|
+
}
|
|
107
|
+
const result = predicate(this.results.ordered[this.state.position].value);
|
|
108
|
+
if (result.isOk() || useAnyways) {
|
|
109
|
+
this.state.used.add(this.state.position);
|
|
110
|
+
++this.state.position;
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
async singleParseAsync(predicate, useAnyways = false) {
|
|
115
|
+
if (this.finished)
|
|
116
|
+
return import_result.Result.err(null);
|
|
117
|
+
while (this.state.used.has(this.state.position)) {
|
|
118
|
+
++this.state.position;
|
|
119
|
+
}
|
|
120
|
+
const result = await predicate(this.results.ordered[this.state.position].value);
|
|
121
|
+
if (result.isOk() || useAnyways) {
|
|
122
|
+
this.state.used.add(this.state.position);
|
|
123
|
+
++this.state.position;
|
|
124
|
+
}
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
find(predicate, from = this.state.position) {
|
|
128
|
+
for (let i = from; i < this.length; ++i) {
|
|
129
|
+
if (this.state.used.has(i))
|
|
130
|
+
continue;
|
|
131
|
+
const parameter = this.results.ordered[i].value;
|
|
132
|
+
if (predicate(parameter)) {
|
|
133
|
+
this.state.used.add(i);
|
|
134
|
+
return import_result.Option.some(parameter);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return import_result.Option.none;
|
|
138
|
+
}
|
|
139
|
+
async findAsync(predicate, from = this.state.position) {
|
|
140
|
+
for (let i = from; i < this.length; ++i) {
|
|
141
|
+
if (this.state.used.has(i))
|
|
142
|
+
continue;
|
|
143
|
+
const parameter = this.results.ordered[i].value;
|
|
144
|
+
if (await predicate(parameter)) {
|
|
145
|
+
this.state.used.add(i);
|
|
146
|
+
return import_result.Option.some(parameter);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return import_result.Option.none;
|
|
150
|
+
}
|
|
151
|
+
findMap(predicate, from = this.state.position) {
|
|
152
|
+
for (let i = from; i < this.length; ++i) {
|
|
153
|
+
if (this.state.used.has(i))
|
|
154
|
+
continue;
|
|
155
|
+
const parameter = this.results.ordered[i].value;
|
|
156
|
+
const result = predicate(parameter);
|
|
157
|
+
if (result.isSome()) {
|
|
158
|
+
this.state.used.add(i);
|
|
159
|
+
return result;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return import_result.Option.none;
|
|
163
|
+
}
|
|
164
|
+
async findMapAsync(predicate, from = this.state.position) {
|
|
165
|
+
for (let i = from; i < this.length; ++i) {
|
|
166
|
+
if (this.state.used.has(i))
|
|
167
|
+
continue;
|
|
168
|
+
const parameter = this.results.ordered[i].value;
|
|
169
|
+
const result = await predicate(parameter);
|
|
170
|
+
if (result.isSome()) {
|
|
171
|
+
this.state.used.add(i);
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return import_result.Option.none;
|
|
176
|
+
}
|
|
177
|
+
findParse(predicate, from = this.state.position) {
|
|
178
|
+
const errors = [];
|
|
179
|
+
for (let i = from; i < this.length; ++i) {
|
|
180
|
+
if (this.state.used.has(i))
|
|
181
|
+
continue;
|
|
182
|
+
const parameter = this.results.ordered[i].value;
|
|
183
|
+
const result = predicate(parameter);
|
|
184
|
+
if (result.isOk()) {
|
|
185
|
+
this.state.used.add(i);
|
|
186
|
+
return result;
|
|
187
|
+
}
|
|
188
|
+
errors.push(result.unwrapErr());
|
|
189
|
+
}
|
|
190
|
+
return import_result.Result.err(errors);
|
|
191
|
+
}
|
|
192
|
+
async findParseAsync(predicate, from = this.state.position) {
|
|
193
|
+
const errors = [];
|
|
194
|
+
for (let i = from; i < this.length; ++i) {
|
|
195
|
+
if (this.state.used.has(i))
|
|
196
|
+
continue;
|
|
197
|
+
const parameter = this.results.ordered[i].value;
|
|
198
|
+
const result = await predicate(parameter);
|
|
199
|
+
if (result.isOk()) {
|
|
200
|
+
this.state.used.add(i);
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
203
|
+
errors.push(result.unwrapErr());
|
|
204
|
+
}
|
|
205
|
+
return import_result.Result.err(errors);
|
|
206
|
+
}
|
|
207
|
+
many(limit = Infinity, from = this.state.position) {
|
|
208
|
+
if (this.finished)
|
|
209
|
+
return import_result.Option.none;
|
|
210
|
+
const parameters = [];
|
|
211
|
+
for (let i = from; i < this.length; ++i) {
|
|
212
|
+
if (this.state.used.has(i))
|
|
213
|
+
continue;
|
|
214
|
+
this.state.used.add(i);
|
|
215
|
+
parameters.push(this.results.ordered[i]);
|
|
216
|
+
if (parameters.length >= limit)
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
return parameters.length ? import_result.Option.some(parameters) : import_result.Option.none;
|
|
220
|
+
}
|
|
221
|
+
filter(predicate, from = this.state.position) {
|
|
222
|
+
if (this.finished)
|
|
223
|
+
return import_result.Option.none;
|
|
224
|
+
const parameters = [];
|
|
225
|
+
for (let i = from; i < this.length; ++i) {
|
|
226
|
+
if (this.state.used.has(i))
|
|
227
|
+
continue;
|
|
228
|
+
const parameter = this.results.ordered[i].value;
|
|
229
|
+
if (predicate(parameter)) {
|
|
230
|
+
this.state.used.add(i);
|
|
231
|
+
parameters.push(parameter);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return import_result.Option.some(parameters);
|
|
235
|
+
}
|
|
236
|
+
async filterAsync(predicate, from = this.state.position) {
|
|
237
|
+
if (this.finished)
|
|
238
|
+
return import_result.Option.none;
|
|
239
|
+
const parameters = [];
|
|
240
|
+
for (let i = from; i < this.length; ++i) {
|
|
241
|
+
if (this.state.used.has(i))
|
|
242
|
+
continue;
|
|
243
|
+
const parameter = this.results.ordered[i].value;
|
|
244
|
+
if (await predicate(parameter)) {
|
|
245
|
+
this.state.used.add(i);
|
|
246
|
+
parameters.push(parameter);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return import_result.Option.some(parameters);
|
|
250
|
+
}
|
|
251
|
+
filterMap(predicate, from = this.state.position) {
|
|
252
|
+
if (this.finished)
|
|
253
|
+
return import_result.Option.none;
|
|
254
|
+
const parameters = [];
|
|
255
|
+
for (let i = from; i < this.length; ++i) {
|
|
256
|
+
if (this.state.used.has(i))
|
|
257
|
+
continue;
|
|
258
|
+
const parameter = this.results.ordered[i].value;
|
|
259
|
+
const result = predicate(parameter);
|
|
260
|
+
result.inspect((value) => {
|
|
261
|
+
this.state.used.add(i);
|
|
262
|
+
parameters.push(value);
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
return import_result.Option.some(parameters);
|
|
266
|
+
}
|
|
267
|
+
async filterMapAsync(predicate, from = this.state.position) {
|
|
268
|
+
if (this.finished)
|
|
269
|
+
return import_result.Option.none;
|
|
270
|
+
const parameters = [];
|
|
271
|
+
for (let i = from; i < this.length; ++i) {
|
|
272
|
+
if (this.state.used.has(i))
|
|
273
|
+
continue;
|
|
274
|
+
const parameter = this.results.ordered[i].value;
|
|
275
|
+
const result = await predicate(parameter);
|
|
276
|
+
result.inspect((value) => {
|
|
277
|
+
this.state.used.add(i);
|
|
278
|
+
parameters.push(value);
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
return import_result.Option.some(parameters);
|
|
282
|
+
}
|
|
283
|
+
flag(...keys) {
|
|
284
|
+
return keys.some((key) => this.results.flags.has(key));
|
|
285
|
+
}
|
|
286
|
+
option(...keys) {
|
|
287
|
+
return this.options(...keys).map((values) => values.at(-1));
|
|
288
|
+
}
|
|
289
|
+
options(...keys) {
|
|
290
|
+
const entries = [];
|
|
291
|
+
for (const key of keys) {
|
|
292
|
+
const values = this.results.options.get(key);
|
|
293
|
+
if (values)
|
|
294
|
+
entries.push(...values);
|
|
295
|
+
}
|
|
296
|
+
return entries.length ? import_result.Option.some(entries) : import_result.Option.none;
|
|
297
|
+
}
|
|
298
|
+
save() {
|
|
299
|
+
return {
|
|
300
|
+
used: new Set(this.state.used),
|
|
301
|
+
position: this.state.position
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
restore(state) {
|
|
305
|
+
this.state = state;
|
|
306
|
+
}
|
|
307
|
+
reset() {
|
|
308
|
+
this.restore({ used: /* @__PURE__ */ new Set(), position: 0 });
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
__name(ArgumentStream, "ArgumentStream");
|
|
312
|
+
|
|
313
|
+
// src/lib/lexer/streams/parameters/BaseParameter.ts
|
|
314
|
+
var BaseParameter = class {
|
|
315
|
+
constructor(separators) {
|
|
316
|
+
__publicField(this, "separators");
|
|
317
|
+
this.separators = separators;
|
|
318
|
+
}
|
|
319
|
+
get leading() {
|
|
320
|
+
return this.separators.join("");
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
__name(BaseParameter, "BaseParameter");
|
|
324
|
+
|
|
325
|
+
// src/lib/lexer/streams/parameters/QuotedParameter.ts
|
|
326
|
+
var QuotedParameter = class extends BaseParameter {
|
|
327
|
+
constructor(separators, part) {
|
|
328
|
+
super(separators);
|
|
329
|
+
__publicField(this, "value");
|
|
330
|
+
__publicField(this, "open");
|
|
331
|
+
__publicField(this, "close");
|
|
332
|
+
this.value = part.value;
|
|
333
|
+
this.open = part.open;
|
|
334
|
+
this.close = part.close;
|
|
335
|
+
}
|
|
336
|
+
get raw() {
|
|
337
|
+
return `${this.open}${this.value}${this.close}`;
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
__name(QuotedParameter, "QuotedParameter");
|
|
341
|
+
|
|
342
|
+
// src/lib/lexer/streams/parameters/WordParameter.ts
|
|
343
|
+
var WordParameter = class extends BaseParameter {
|
|
344
|
+
constructor(separators, part) {
|
|
345
|
+
super(separators);
|
|
346
|
+
__publicField(this, "value");
|
|
347
|
+
this.value = part.value;
|
|
348
|
+
}
|
|
349
|
+
get raw() {
|
|
350
|
+
return this.value;
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
__name(WordParameter, "WordParameter");
|
|
354
|
+
|
|
355
|
+
// src/lib/lexer/streams/raw/TokenStream.ts
|
|
356
|
+
var TokenStream = class {
|
|
357
|
+
constructor(lexer, input) {
|
|
358
|
+
__publicField(this, "input");
|
|
359
|
+
__publicField(this, "quotes");
|
|
360
|
+
__publicField(this, "separator");
|
|
361
|
+
__publicField(this, "position", 0);
|
|
362
|
+
this.quotes = lexer.quotes;
|
|
363
|
+
this.separator = lexer.separator;
|
|
364
|
+
this.input = input;
|
|
365
|
+
}
|
|
366
|
+
get finished() {
|
|
367
|
+
return this.position >= this.input.length;
|
|
368
|
+
}
|
|
369
|
+
*[Symbol.iterator]() {
|
|
370
|
+
while (!this.finished) {
|
|
371
|
+
yield this.getPossibleSeparator() ?? this.getPossibleQuotedArgument() ?? this.getParameter();
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
getPossibleSeparator() {
|
|
375
|
+
if (this.input.startsWith(this.separator, this.position)) {
|
|
376
|
+
this.position += this.separator.length;
|
|
377
|
+
return { type: TokenType.Separator, value: this.separator };
|
|
378
|
+
}
|
|
379
|
+
return null;
|
|
380
|
+
}
|
|
381
|
+
getPossibleQuotedArgument() {
|
|
382
|
+
for (const [open, close] of this.quotes) {
|
|
383
|
+
if (!this.input.startsWith(open, this.position))
|
|
384
|
+
continue;
|
|
385
|
+
const end = this.input.indexOf(close, this.position + open.length);
|
|
386
|
+
if (end === -1)
|
|
387
|
+
continue;
|
|
388
|
+
const value = this.input.slice(this.position + open.length, end);
|
|
389
|
+
this.position = end + close.length;
|
|
390
|
+
return { type: TokenType.Quoted, value, open, close };
|
|
391
|
+
}
|
|
392
|
+
return null;
|
|
393
|
+
}
|
|
394
|
+
getParameter() {
|
|
395
|
+
const index = this.input.indexOf(this.separator, this.position);
|
|
396
|
+
const value = index === -1 ? this.input.slice(this.position) : this.input.slice(this.position, index);
|
|
397
|
+
this.position += value.length;
|
|
398
|
+
return { type: TokenType.Parameter, value };
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
__name(TokenStream, "TokenStream");
|
|
402
|
+
var TokenType = /* @__PURE__ */ ((TokenType2) => {
|
|
403
|
+
TokenType2[TokenType2["Parameter"] = 0] = "Parameter";
|
|
404
|
+
TokenType2[TokenType2["Quoted"] = 1] = "Quoted";
|
|
405
|
+
TokenType2[TokenType2["Separator"] = 2] = "Separator";
|
|
406
|
+
return TokenType2;
|
|
407
|
+
})(TokenType || {});
|
|
408
|
+
|
|
409
|
+
// src/lib/lexer/streams/ParameterStream.ts
|
|
410
|
+
var ParameterStream = class {
|
|
411
|
+
constructor(stream) {
|
|
412
|
+
__publicField(this, "stream");
|
|
413
|
+
__publicField(this, "separators", []);
|
|
414
|
+
this.stream = stream;
|
|
415
|
+
}
|
|
416
|
+
*[Symbol.iterator]() {
|
|
417
|
+
for (const part of this.stream) {
|
|
418
|
+
if (part.type === 2 /* Separator */) {
|
|
419
|
+
this.separators.push(part.value);
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
yield part.type === 1 /* Quoted */ ? new QuotedParameter(this.separators, part) : new WordParameter(this.separators, part);
|
|
423
|
+
this.separators = [];
|
|
424
|
+
}
|
|
425
|
+
return this.separators;
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
__name(ParameterStream, "ParameterStream");
|
|
429
|
+
|
|
430
|
+
// src/lib/lexer/Lexer.ts
|
|
431
|
+
var Lexer = class {
|
|
432
|
+
constructor(options = {}) {
|
|
433
|
+
__publicField(this, "quotes");
|
|
434
|
+
__publicField(this, "separator");
|
|
435
|
+
this.quotes = options.quotes ?? [];
|
|
436
|
+
this.separator = options.separator ?? " ";
|
|
437
|
+
}
|
|
438
|
+
run(input) {
|
|
439
|
+
return new ParameterStream(this.raw(input));
|
|
440
|
+
}
|
|
441
|
+
raw(input) {
|
|
442
|
+
return new TokenStream(this, input);
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
__name(Lexer, "Lexer");
|
|
446
|
+
|
|
447
|
+
// src/lib/parser/ParserResult.ts
|
|
448
|
+
var ParserResult = class {
|
|
449
|
+
constructor(parser) {
|
|
450
|
+
__publicField(this, "ordered", []);
|
|
451
|
+
__publicField(this, "flags", /* @__PURE__ */ new Set());
|
|
452
|
+
__publicField(this, "options", /* @__PURE__ */ new Map());
|
|
453
|
+
__publicField(this, "strategy");
|
|
454
|
+
this.strategy = parser.strategy;
|
|
455
|
+
}
|
|
456
|
+
parse(parameters) {
|
|
457
|
+
for (const parameter of parameters) {
|
|
458
|
+
this.parsePossibleFlag(parameter) || this.parsePossibleOptions(parameter) || this.parseOrdered(parameter);
|
|
459
|
+
}
|
|
460
|
+
return this;
|
|
461
|
+
}
|
|
462
|
+
parsePossibleFlag(parameter) {
|
|
463
|
+
return this.strategy.matchFlag(parameter.value).inspect((value) => this.flags.add(value)).isSome();
|
|
464
|
+
}
|
|
465
|
+
parsePossibleOptions(parameter) {
|
|
466
|
+
return this.strategy.matchOption(parameter.value).inspect(([key, value]) => {
|
|
467
|
+
const existing = this.options.get(key);
|
|
468
|
+
if (existing)
|
|
469
|
+
existing.push(value);
|
|
470
|
+
else
|
|
471
|
+
this.options.set(key, [value]);
|
|
472
|
+
}).isSome();
|
|
473
|
+
}
|
|
474
|
+
parseOrdered(parameter) {
|
|
475
|
+
this.ordered.push(parameter);
|
|
476
|
+
return true;
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
__name(ParserResult, "ParserResult");
|
|
480
|
+
|
|
481
|
+
// src/lib/parser/strategies/EmptyStrategy.ts
|
|
482
|
+
var import_result2 = require("@sapphire/result");
|
|
483
|
+
var EmptyStrategy = class {
|
|
484
|
+
matchFlag() {
|
|
485
|
+
return import_result2.Option.none;
|
|
486
|
+
}
|
|
487
|
+
matchOption() {
|
|
488
|
+
return import_result2.Option.none;
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
__name(EmptyStrategy, "EmptyStrategy");
|
|
492
|
+
|
|
493
|
+
// src/lib/parser/Parser.ts
|
|
494
|
+
var Parser = class {
|
|
495
|
+
constructor(strategy) {
|
|
496
|
+
__publicField(this, "strategy");
|
|
497
|
+
this.strategy = strategy ?? new EmptyStrategy();
|
|
498
|
+
}
|
|
499
|
+
setUnorderedStrategy(strategy) {
|
|
500
|
+
this.strategy = strategy;
|
|
501
|
+
return this;
|
|
502
|
+
}
|
|
503
|
+
run(input) {
|
|
504
|
+
return new ParserResult(this).parse(input);
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
__name(Parser, "Parser");
|
|
508
|
+
|
|
509
|
+
// src/lib/parser/strategies/PrefixedStrategy.ts
|
|
510
|
+
var import_result3 = require("@sapphire/result");
|
|
511
|
+
var PrefixedStrategy = class {
|
|
512
|
+
constructor(prefixes, separators) {
|
|
513
|
+
__publicField(this, "prefixes");
|
|
514
|
+
__publicField(this, "separators");
|
|
515
|
+
this.prefixes = prefixes;
|
|
516
|
+
this.separators = separators;
|
|
517
|
+
}
|
|
518
|
+
matchFlag(input) {
|
|
519
|
+
const prefix = this.prefixes.find((x) => input.startsWith(x));
|
|
520
|
+
if (!prefix)
|
|
521
|
+
return import_result3.Option.none;
|
|
522
|
+
if (this.separators.some((x) => input.includes(x, prefix.length)))
|
|
523
|
+
return import_result3.Option.none;
|
|
524
|
+
return import_result3.Option.some(input.slice(prefix.length));
|
|
525
|
+
}
|
|
526
|
+
matchOption(input) {
|
|
527
|
+
const prefix = this.prefixes.find((x) => input.startsWith(x));
|
|
528
|
+
if (!prefix)
|
|
529
|
+
return import_result3.Option.none;
|
|
530
|
+
for (const separator of this.separators) {
|
|
531
|
+
const index = input.indexOf(separator, prefix.length + 1);
|
|
532
|
+
if (index === -1)
|
|
533
|
+
continue;
|
|
534
|
+
if (index + separator.length === input.length)
|
|
535
|
+
return import_result3.Option.none;
|
|
536
|
+
const key = input.slice(prefix.length, index);
|
|
537
|
+
const value = input.slice(index + separator.length);
|
|
538
|
+
return import_result3.Option.some([key, value]);
|
|
539
|
+
}
|
|
540
|
+
return import_result3.Option.none;
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
__name(PrefixedStrategy, "PrefixedStrategy");
|
|
544
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
545
|
+
0 && (module.exports = {
|
|
546
|
+
ArgumentStream,
|
|
547
|
+
BaseParameter,
|
|
548
|
+
EmptyStrategy,
|
|
549
|
+
Lexer,
|
|
550
|
+
ParameterStream,
|
|
551
|
+
Parser,
|
|
552
|
+
ParserResult,
|
|
553
|
+
PrefixedStrategy,
|
|
554
|
+
QuotedParameter,
|
|
555
|
+
TokenStream,
|
|
556
|
+
TokenType,
|
|
557
|
+
WordParameter
|
|
558
|
+
});
|
|
559
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/lib/ArgumentStream.ts","../src/lib/lexer/streams/parameters/BaseParameter.ts","../src/lib/lexer/streams/parameters/QuotedParameter.ts","../src/lib/lexer/streams/parameters/WordParameter.ts","../src/lib/lexer/streams/raw/TokenStream.ts","../src/lib/lexer/streams/ParameterStream.ts","../src/lib/lexer/Lexer.ts","../src/lib/parser/ParserResult.ts","../src/lib/parser/strategies/EmptyStrategy.ts","../src/lib/parser/Parser.ts","../src/lib/parser/strategies/PrefixedStrategy.ts"],"sourcesContent":["export * from './lib/ArgumentStream';\nexport * from './lib/lexer/Lexer';\nexport * from './lib/lexer/streams/parameters/BaseParameter';\nexport * from './lib/lexer/streams/parameters/QuotedParameter';\nexport * from './lib/lexer/streams/parameters/WordParameter';\nexport * from './lib/lexer/streams/ParameterStream';\nexport * from './lib/lexer/streams/raw/TokenStream';\nexport * from './lib/parser/Parser';\nexport * from './lib/parser/ParserResult';\nexport * from './lib/parser/strategies/EmptyStrategy';\nexport * from './lib/parser/strategies/IUnorderedStrategy';\nexport * from './lib/parser/strategies/PrefixedStrategy';\n","import { Option, Result } from '@sapphire/result';\nimport type { Parameter } from './lexer/streams/ParameterStream';\nimport type { ParserResult } from './parser/ParserResult';\n\nexport class ArgumentStream {\n\tpublic readonly results: ParserResult;\n\tpublic state: ArgumentStream.State;\n\n\tpublic constructor(results: ParserResult) {\n\t\tthis.results = results;\n\t\tthis.state = { used: new Set(), position: 0 };\n\t}\n\n\t/**\n\t * Whether or not all ordered parameters were used.\n\t */\n\tpublic get finished() {\n\t\treturn this.used === this.length;\n\t}\n\n\t/**\n\t * The amount of ordered parameters.\n\t */\n\tpublic get length() {\n\t\treturn this.results.ordered.length;\n\t}\n\n\t/**\n\t * The remaining amount of ordered parameters.\n\t */\n\tpublic get remaining() {\n\t\treturn this.length - this.used;\n\t}\n\n\t/**\n\t * The amount of ordered parameters that have been used.\n\t */\n\tpublic get used() {\n\t\treturn this.state.used.size;\n\t}\n\n\t/**\n\t * Retrieves the value of the next unused ordered token.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Assume args are '1 2 3':\n\t *\n\t * console.log(args.single());\n\t * // Ok { value: '1' }\n\t *\n\t * console.log(args.single());\n\t * // Ok { value: '2' }\n\t *\n\t * console.log(args.single());\n\t * // Ok { value: '3' }\n\t *\n\t * console.log(args.single());\n\t * // None\n\t * ```\n\t *\n\t * @returns The value, if any.\n\t */\n\tpublic single(): Option<string> {\n\t\tif (this.finished) return Option.none;\n\n\t\twhile (this.state.used.has(this.state.position)) {\n\t\t\t++this.state.position;\n\t\t}\n\n\t\tthis.state.used.add(this.state.position);\n\t\treturn Option.some(this.results.ordered[this.state.position++].value);\n\t}\n\n\t/**\n\t * Retrieves the value of the next unused ordered token, but only if it could be transformed.\n\t *\n\t * @note This does not support asynchronous results, refer to {@link singleMapAsync}.\n\t *\n\t * @example\n\t * ```typescript\n\t * const parse = (value) => {\n\t * const number = Number(value);\n\t * return Number.isNaN(number) ? Option.none : Option.some(number);\n\t * };\n\t *\n\t * // Assume args are '1 2 3':\n\t *\n\t * console.log(args.singleMap(parse));\n\t * // Some { value: 1 }\n\t *\n\t * console.log(args.singleMap(parse));\n\t * // Some { value: 2 }\n\t *\n\t * console.log(args.singleMap(parse));\n\t * // Some { value: 3 }\n\t *\n\t * console.log(args.singleMap(parse));\n\t * // None\n\t * ```\n\t *\n\t * @typeparam T The output type.\n\t * @param predicate The predicate that determines the parameter's mapped value, or nothing if failed.\n\t * @param useAnyways Whether to consider the parameter used even if the mapping failed. Defaults to `false`.\n\t * @returns The mapped value, if any.\n\t */\n\tpublic singleMap<T>(predicate: (value: string) => Option<T>, useAnyways = false): Option<T> {\n\t\tif (this.finished) return Option.none;\n\n\t\twhile (this.state.used.has(this.state.position)) {\n\t\t\t++this.state.position;\n\t\t}\n\n\t\tconst result = predicate(this.results.ordered[this.state.position].value);\n\t\tif (result.isSome() || useAnyways) {\n\t\t\tthis.state.used.add(this.state.position);\n\t\t\t++this.state.position;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Retrieves the value of the next unused ordered token, but only if it could be transformed.\n\t *\n\t * @note This is an asynchronous variant of {@link singleMap}.\n\t *\n\t * @typeparam T The output type.\n\t * @param predicate The predicate that determines the parameter's mapped value, or nothing if failed.\n\t * @param useAnyways Whether to consider the parameter used even if the mapping failed. Defaults to `false`.\n\t * @returns The mapped value, if any.\n\t */\n\tpublic async singleMapAsync<T>(predicate: (value: string) => Promise<Option<T>>, useAnyways = false): Promise<Option<T>> {\n\t\tif (this.finished) return Option.none;\n\n\t\twhile (this.state.used.has(this.state.position)) {\n\t\t\t++this.state.position;\n\t\t}\n\n\t\tconst result = await predicate(this.results.ordered[this.state.position].value);\n\t\tif (result.isSome() || useAnyways) {\n\t\t\tthis.state.used.add(this.state.position);\n\t\t\t++this.state.position;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Finds and retrieves the next unused parameter and transforms it.\n\t *\n\t * @note This is a variant of {@link findMap} that returns the errors on failure.\n\t * @note This does not support asynchronous results, refer to {@link singleParseAsync}.\n\t *\n\t * @example\n\t * ```typescript\n\t * const parse = (value) => {\n\t * const number = Number(value);\n\t * return Number.isNaN(number)\n\t * ? Result.err(`Could not parse ${value} to a number`)\n\t * : Result.ok(number);\n\t * };\n\t *\n\t * // Assume args are '1 2 3':\n\t *\n\t * console.log(args.singleParse(parse));\n\t * // Ok { value: 1 }\n\t *\n\t * console.log(args.singleParse(parse));\n\t * // Ok { value: 2 }\n\t *\n\t * console.log(args.singleParse(parse));\n\t * // Ok { value: 3 }\n\t *\n\t * console.log(args.singleParse(parse));\n\t * // Err { error: null }\n\t * ```\n\t *\n\t * @typeparam T The output type.\n\t * @typeparam E The error type.\n\t * @param predicate The predicate that determines the parameter's transformed value, or nothing if failed.\n\t * @param useAnyways Whether to consider the parameter used even if the transformation failed. Defaults to `false`.\n\t * @returns The transformed value, if any.\n\t */\n\tpublic singleParse<T, E>(predicate: (value: string) => Result<T, E>, useAnyways = false): Result<T, E | null> {\n\t\tif (this.finished) return Result.err(null);\n\n\t\twhile (this.state.used.has(this.state.position)) {\n\t\t\t++this.state.position;\n\t\t}\n\n\t\tconst result = predicate(this.results.ordered[this.state.position].value);\n\t\tif (result.isOk() || useAnyways) {\n\t\t\tthis.state.used.add(this.state.position);\n\t\t\t++this.state.position;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Retrieves the value of the next unused ordered token, but only if it could be transformed.\n\t *\n\t * @note This is an asynchronous variant of {@link singleParse}.\n\t *\n\t * @typeparam T The output type.\n\t * @typeparam E The error type.\n\t * @param predicate The predicate that determines the parameter's mapped value, or nothing if failed.\n\t * @param useAnyways Whether to consider the parameter used even if the mapping failed. Defaults to `false`.\n\t * @returns The mapped value, if any.\n\t */\n\tpublic async singleParseAsync<T, E>(predicate: (value: string) => Promise<Result<T, E>>, useAnyways = false): Promise<Result<T, E | null>> {\n\t\tif (this.finished) return Result.err(null);\n\n\t\twhile (this.state.used.has(this.state.position)) {\n\t\t\t++this.state.position;\n\t\t}\n\n\t\tconst result = await predicate(this.results.ordered[this.state.position].value);\n\t\tif (result.isOk() || useAnyways) {\n\t\t\tthis.state.used.add(this.state.position);\n\t\t\t++this.state.position;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Returns the value of the first element in the array within `Option.some` where `predicate` returns `true`, and\n\t * `Option.none` otherwise.\n\t *\n\t * @note This does not support asynchronous results, refer to {@link findAsync}.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Suppose args are from 'ba aa cc'.\n\t *\n\t * console.log(args.find((value) => value.startsWith('a')));\n\t * // Some { value: 'aa' }\n\t * ```\n\t *\n\t * @param predicate find calls `predicate` once for each unused ordered parameter, in ascending order, until it\n\t * finds one where `predicate` returns `true`. If such an element is found, find immediately returns a `Option.some`\n\t * with that element value. Otherwise, find returns `Option.none`.\n\t * @param from The position where to start looking for unused parameters, defaults to current position.\n\t * @returns The found parameter's value.\n\t */\n\tpublic find(predicate: (value: string) => boolean, from = this.state.position): Option<string> {\n\t\tfor (let i = from; i < this.length; ++i) {\n\t\t\tif (this.state.used.has(i)) continue;\n\n\t\t\tconst parameter = this.results.ordered[i].value;\n\t\t\tif (predicate(parameter)) {\n\t\t\t\tthis.state.used.add(i);\n\t\t\t\treturn Option.some(parameter);\n\t\t\t}\n\t\t}\n\n\t\treturn Option.none;\n\t}\n\n\t/**\n\t * Returns the value of the first element in the array within `Option.some` where `predicate` returns `true`, and\n\t * `Option.none` otherwise.\n\t *\n\t * @note This is an asynchronous variant of {@link find}.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Suppose args are from 'ba aa cc'.\n\t *\n\t * console.log(args.find((value) => value.startsWith('a')));\n\t * // Some { value: 'aa' }\n\t * ```\n\t *\n\t * @param predicate find calls `predicate` once for each unused ordered parameter, in ascending order, until it\n\t * finds one where `predicate` returns `true`. If such an element is found, find immediately returns a `Option.some`\n\t * with that element value. Otherwise, find returns `Option.none`.\n\t * @param from The position where to start looking for unused parameters, defaults to current position.\n\t * @returns The found parameter's value.\n\t */\n\tpublic async findAsync(predicate: (value: string) => Promise<boolean>, from = this.state.position): Promise<Option<string>> {\n\t\tfor (let i = from; i < this.length; ++i) {\n\t\t\tif (this.state.used.has(i)) continue;\n\n\t\t\tconst parameter = this.results.ordered[i].value;\n\t\t\tif (await predicate(parameter)) {\n\t\t\t\tthis.state.used.add(i);\n\t\t\t\treturn Option.some(parameter);\n\t\t\t}\n\t\t}\n\n\t\treturn Option.none;\n\t}\n\n\t/**\n\t * Returns the value of the first element in the array within `Option.some` where `predicate` returns `Some`, and\n\t * `Option.none` otherwise.\n\t *\n\t * @note This does not support asynchronous results, refer to {@link findMapAsync}.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Suppose args are from 'ba aa cc'.\n\t *\n\t * console.log(args.find((value) => value.startsWith('a')));\n\t * // Some { value: 'aa' }\n\t * ```\n\t *\n\t * @typeparam T The output type.\n\t * @param predicate find calls `predicate` once for each unused ordered parameter, in ascending order, until it\n\t * finds one where `predicate` returns `Some`. If such an element is found, find immediately returns the returned\n\t * value. Otherwise, find returns `Option.none`.\n\t * @param from The position where to start looking for unused parameters, defaults to current position.\n\t * @returns The found parameter's value.\n\t */\n\tpublic findMap<T>(predicate: (value: string) => Option<T>, from = this.state.position): Option<T> {\n\t\tfor (let i = from; i < this.length; ++i) {\n\t\t\tif (this.state.used.has(i)) continue;\n\n\t\t\tconst parameter = this.results.ordered[i].value;\n\t\t\tconst result = predicate(parameter);\n\t\t\tif (result.isSome()) {\n\t\t\t\tthis.state.used.add(i);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\n\t\treturn Option.none;\n\t}\n\n\t/**\n\t * Returns the value of the first element in the array within `Option.some` where `predicate` returns `Some`, and\n\t * `Option.none` otherwise.\n\t *\n\t * @note This is an asynchronous variant of {@link findMap}.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Suppose args are from 'ba aa cc'.\n\t *\n\t * console.log(args.find((value) => value.startsWith('a')));\n\t * // Some { value: 'aa' }\n\t * ```\n\t *\n\t * @typeparam T The output type.\n\t * @param predicate find calls `predicate` once for each unused ordered parameter, in ascending order, until it\n\t * finds one where `predicate` returns `Some`. If such an element is found, find immediately returns the returned\n\t * value. Otherwise, find returns `Option.none`.\n\t * @param from The position where to start looking for unused parameters, defaults to current position.\n\t * @returns The found parameter's value.\n\t */\n\tpublic async findMapAsync<T>(predicate: (value: string) => Promise<Option<T>>, from = this.state.position): Promise<Option<T>> {\n\t\tfor (let i = from; i < this.length; ++i) {\n\t\t\tif (this.state.used.has(i)) continue;\n\n\t\t\tconst parameter = this.results.ordered[i].value;\n\t\t\tconst result = await predicate(parameter);\n\t\t\tif (result.isSome()) {\n\t\t\t\tthis.state.used.add(i);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\n\t\treturn Option.none;\n\t}\n\n\t/**\n\t * Finds and retrieves the first unused parameter that could be transformed.\n\t *\n\t * @note This is a variant of {@link findMap} that returns the errors on failure.\n\t * @note This does not support asynchronous results, refer to {@link findParseAsync}.\n\t *\n\t * @example\n\t * ```typescript\n\t * const parse = (value) => {\n\t * const number = Number(value);\n\t * return Number.isNaN(number)\n\t * ? Result.err(`Could not parse ${value} to a number`)\n\t * : Result.ok(number);\n\t * };\n\t *\n\t * // Suppose args are from 'ba 1 cc'.\n\t *\n\t * console.log(args.findParse(parse));\n\t * // Ok { value: 1 }\n\t *\n\t * console.log(args.findParse(parse));\n\t * // Err {\n\t * // error: [\n\t * // 'Could not parse ba to a number',\n\t * // 'Could not parse cc to a number'\n\t * // ]\n\t * // }\n\t * ```\n\t *\n\t * @typeparam T The output type.\n\t * @typeparam E The error type.\n\t * @param predicate `findParse` calls `predicate` once for each unused ordered parameter, in ascending order, until\n\t * it finds one where `predicate` returns `Ok`. If such an element is found, `findParse` immediately returns the\n\t * returned value. Otherwise, `findParse` returns `Result.Err` with all the returned errors.\n\t * @param from The position where to start looking for unused parameters, defaults to current position.\n\t * @returns The found parameter's value.\n\t */\n\tpublic findParse<T, E>(predicate: (value: string) => Result<T, E>, from = this.state.position): Result<T, E[]> {\n\t\tconst errors: E[] = [];\n\t\tfor (let i = from; i < this.length; ++i) {\n\t\t\tif (this.state.used.has(i)) continue;\n\n\t\t\tconst parameter = this.results.ordered[i].value;\n\t\t\tconst result = predicate(parameter);\n\t\t\tif (result.isOk()) {\n\t\t\t\tthis.state.used.add(i);\n\t\t\t\treturn result as Result.Ok<T>;\n\t\t\t}\n\n\t\t\terrors.push(result.unwrapErr());\n\t\t}\n\n\t\treturn Result.err(errors);\n\t}\n\n\t/**\n\t * Finds and retrieves the first unused parameter that could be transformed.\n\t *\n\t * @note This is a variant of {@link findMapAsync} that returns the errors on failure.\n\t * @note This is an asynchronous variant of {@link findParse}.\n\t *\n\t * @typeparam T The output type.\n\t * @typeparam E The error type.\n\t * @param predicate `findParse` calls `predicate` once for each unused ordered parameter, in ascending order, until\n\t * it finds one where `predicate` returns `Ok`. If such an element is found, `findParse` immediately returns the\n\t * returned value. Otherwise, `findParse` returns `Result.Err` with all the returned errors.\n\t * @param from The position where to start looking for unused parameters, defaults to current position.\n\t * @returns The found parameter's value.\n\t */\n\tpublic async findParseAsync<T, E>(predicate: (value: string) => Promise<Result<T, E>>, from = this.state.position): Promise<Result<T, E[]>> {\n\t\tconst errors: E[] = [];\n\t\tfor (let i = from; i < this.length; ++i) {\n\t\t\tif (this.state.used.has(i)) continue;\n\n\t\t\tconst parameter = this.results.ordered[i].value;\n\t\t\tconst result = await predicate(parameter);\n\t\t\tif (result.isOk()) {\n\t\t\t\tthis.state.used.add(i);\n\t\t\t\treturn result as Result.Ok<T>;\n\t\t\t}\n\n\t\t\terrors.push(result.unwrapErr());\n\t\t}\n\n\t\treturn Result.err(errors);\n\t}\n\n\t/**\n\t * Retrieves multiple unused parameters.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Assume args are '1 2 3':\n\t *\n\t * console.log(join(args.many().unwrap()));\n\t * // '1 2 3'\n\t * ```\n\t *\n\t * @example\n\t * ```typescript\n\t * // Assume args are '1 2 3':\n\t *\n\t * console.log(join(args.many(2).unwrap()));\n\t * // '1 2'\n\t * ```\n\t *\n\t * @param limit The maximum amount of parameters to retrieve, defaults to `Infinity`.\n\t * @param from The position where to start looking for unused parameters, defaults to current position.\n\t * @returns The unused parameters within the range.\n\t */\n\tpublic many(limit = Infinity, from = this.state.position): Option<Parameter[]> {\n\t\tif (this.finished) return Option.none;\n\n\t\tconst parameters: Parameter[] = [];\n\t\tfor (let i = from; i < this.length; ++i) {\n\t\t\t// If the current parameter was already used, skip:\n\t\t\tif (this.state.used.has(i)) continue;\n\n\t\t\t// Mark current parameter as used, and push it to the resulting array:\n\t\t\tthis.state.used.add(i);\n\t\t\tparameters.push(this.results.ordered[i]);\n\n\t\t\t// If the parameters reached the limit, break the loop:\n\t\t\tif (parameters.length >= limit) break;\n\t\t}\n\n\t\treturn parameters.length ? Option.some(parameters) : Option.none;\n\t}\n\n\tpublic filter(predicate: (value: string) => boolean, from = this.state.position): Option<string[]> {\n\t\tif (this.finished) return Option.none;\n\n\t\tconst parameters: string[] = [];\n\t\tfor (let i = from; i < this.length; ++i) {\n\t\t\tif (this.state.used.has(i)) continue;\n\n\t\t\tconst parameter = this.results.ordered[i].value;\n\t\t\tif (predicate(parameter)) {\n\t\t\t\tthis.state.used.add(i);\n\t\t\t\tparameters.push(parameter);\n\t\t\t}\n\t\t}\n\n\t\treturn Option.some(parameters);\n\t}\n\n\tpublic async filterAsync(predicate: (value: string) => Promise<boolean>, from = this.state.position): Promise<Option<string[]>> {\n\t\tif (this.finished) return Option.none;\n\n\t\tconst parameters: string[] = [];\n\t\tfor (let i = from; i < this.length; ++i) {\n\t\t\tif (this.state.used.has(i)) continue;\n\n\t\t\tconst parameter = this.results.ordered[i].value;\n\t\t\tif (await predicate(parameter)) {\n\t\t\t\tthis.state.used.add(i);\n\t\t\t\tparameters.push(parameter);\n\t\t\t}\n\t\t}\n\n\t\treturn Option.some(parameters);\n\t}\n\n\tpublic filterMap<T>(predicate: (value: string) => Option<T>, from = this.state.position): Option<T[]> {\n\t\tif (this.finished) return Option.none;\n\n\t\tconst parameters: T[] = [];\n\t\tfor (let i = from; i < this.length; ++i) {\n\t\t\tif (this.state.used.has(i)) continue;\n\n\t\t\tconst parameter = this.results.ordered[i].value;\n\t\t\tconst result = predicate(parameter);\n\t\t\tresult.inspect((value) => {\n\t\t\t\tthis.state.used.add(i);\n\t\t\t\tparameters.push(value);\n\t\t\t});\n\t\t}\n\n\t\treturn Option.some(parameters);\n\t}\n\n\tpublic async filterMapAsync<T>(predicate: (value: string) => Promise<Option<T>>, from = this.state.position): Promise<Option<T[]>> {\n\t\tif (this.finished) return Option.none;\n\n\t\tconst parameters: T[] = [];\n\t\tfor (let i = from; i < this.length; ++i) {\n\t\t\tif (this.state.used.has(i)) continue;\n\n\t\t\tconst parameter = this.results.ordered[i].value;\n\t\t\tconst result = await predicate(parameter);\n\t\t\tresult.inspect((value) => {\n\t\t\t\tthis.state.used.add(i);\n\t\t\t\tparameters.push(value);\n\t\t\t});\n\t\t}\n\n\t\treturn Option.some(parameters);\n\t}\n\n\t/**\n\t * Checks whether any of the flags were given.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Assume args are '--f --g':\n\t *\n\t * console.log(args.flag('f'));\n\t * // true\n\t *\n\t * console.log(args.flag('g', 'h'));\n\t * // true\n\t *\n\t * console.log(args.flag('h'));\n\t * // false\n\t * ```\n\t *\n\t * @param keys The names of the flags to check.\n\t * @returns Whether or not any of the flags were given.\n\t */\n\tpublic flag(...keys: readonly string[]): boolean {\n\t\treturn keys.some((key) => this.results.flags.has(key));\n\t}\n\n\t/**\n\t * Gets the last value of any option. When there are multiple names, the last value of the last found name is given.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Assume args are '--a=1 --b=2 --c=3'.\n\t * console.log(args.option('a'));\n\t * // Some { value: '1' }\n\t *\n\t * console.log(args.option('b', 'c'));\n\t * // Some { value: '3' }\n\t *\n\t * console.log(args.option('d'));\n\t * // None {}\n\t * ```\n\t *\n\t * @param keys The names of the options to check.\n\t * @returns The last value of the option, if any.\n\t */\n\tpublic option(...keys: readonly string[]): Option<string> {\n\t\treturn this.options(...keys).map((values) => values.at(-1)!);\n\t}\n\n\t/**\n\t * Gets all values from all options.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Assume args are '--a=1 --a=1 --b=2 --c=3'.\n\t * console.log(args.option('a'));\n\t * // Some { value: ['1', '1'] }\n\t *\n\t * console.log(args.option('b', 'c'));\n\t * // Some { value: ['2', '3'] }\n\t *\n\t * console.log(args.option('d'));\n\t * // None {}\n\t * ```\n\t *\n\t * @param keys The names of the options to check.\n\t * @returns The values from all the options concatenated, if any.\n\t */\n\tpublic options(...keys: readonly string[]): Option<readonly string[]> {\n\t\tconst entries: string[] = [];\n\t\tfor (const key of keys) {\n\t\t\tconst values = this.results.options.get(key);\n\t\t\tif (values) entries.push(...values);\n\t\t}\n\n\t\treturn entries.length ? Option.some(entries) : Option.none;\n\t}\n\n\tpublic save(): ArgumentStream.State {\n\t\treturn {\n\t\t\tused: new Set(this.state.used),\n\t\t\tposition: this.state.position\n\t\t};\n\t}\n\n\tpublic restore(state: ArgumentStream.State) {\n\t\tthis.state = state;\n\t}\n\n\tpublic reset() {\n\t\tthis.restore({ used: new Set(), position: 0 });\n\t}\n}\n\nexport namespace ArgumentStream {\n\texport interface State {\n\t\tused: Set<number>;\n\t\tposition: number;\n\t}\n}\n","export abstract class BaseParameter {\n\tpublic readonly separators: readonly string[];\n\n\tpublic constructor(separators: readonly string[]) {\n\t\tthis.separators = separators;\n\t}\n\n\tpublic get leading(): string {\n\t\treturn this.separators.join('');\n\t}\n\n\tpublic abstract get raw(): string;\n}\n","import type { QuotedToken } from '../raw/TokenStream';\nimport { BaseParameter } from './BaseParameter';\n\nexport class QuotedParameter extends BaseParameter {\n\tpublic readonly value: string;\n\tpublic readonly open: string;\n\tpublic readonly close: string;\n\n\tpublic constructor(separators: readonly string[], part: Omit<QuotedToken, 'type'>) {\n\t\tsuper(separators);\n\t\tthis.value = part.value;\n\t\tthis.open = part.open;\n\t\tthis.close = part.close;\n\t}\n\n\tpublic get raw() {\n\t\treturn `${this.open}${this.value}${this.close}`;\n\t}\n}\n","import type { WordToken } from '../raw/TokenStream';\nimport { BaseParameter } from './BaseParameter';\n\nexport class WordParameter extends BaseParameter {\n\tpublic readonly value: string;\n\n\tpublic constructor(separators: readonly string[], part: Omit<WordToken, 'type'>) {\n\t\tsuper(separators);\n\t\tthis.value = part.value;\n\t}\n\n\tpublic get raw() {\n\t\treturn this.value;\n\t}\n}\n","import type { Lexer } from '../../Lexer';\n\nexport class TokenStream implements Iterable<Token> {\n\tprivate readonly input: string;\n\tprivate readonly quotes: readonly [string, string][];\n\tprivate readonly separator: string;\n\tprivate position = 0;\n\n\tpublic constructor(lexer: Lexer, input: string) {\n\t\tthis.quotes = lexer.quotes;\n\t\tthis.separator = lexer.separator;\n\t\tthis.input = input;\n\t}\n\n\tpublic get finished() {\n\t\treturn this.position >= this.input.length;\n\t}\n\n\tpublic *[Symbol.iterator](): Iterator<Token> {\n\t\twhile (!this.finished) {\n\t\t\tyield this.getPossibleSeparator() ?? this.getPossibleQuotedArgument() ?? this.getParameter();\n\t\t}\n\t}\n\n\tprivate getPossibleSeparator(): SeparatorToken | null {\n\t\tif (this.input.startsWith(this.separator, this.position)) {\n\t\t\tthis.position += this.separator.length;\n\t\t\treturn { type: TokenType.Separator, value: this.separator };\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tprivate getPossibleQuotedArgument(): QuotedToken | null {\n\t\tfor (const [open, close] of this.quotes) {\n\t\t\tif (!this.input.startsWith(open, this.position)) continue;\n\n\t\t\tconst end = this.input.indexOf(close, this.position + open.length);\n\t\t\tif (end === -1) continue;\n\n\t\t\tconst value = this.input.slice(this.position + open.length, end);\n\t\t\tthis.position = end + close.length;\n\n\t\t\treturn { type: TokenType.Quoted, value, open, close };\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tprivate getParameter(): WordToken {\n\t\tconst index = this.input.indexOf(this.separator, this.position);\n\t\tconst value = index === -1 ? this.input.slice(this.position) : this.input.slice(this.position, index);\n\t\tthis.position += value.length;\n\t\treturn { type: TokenType.Parameter, value };\n\t}\n}\n\nexport enum TokenType {\n\tParameter,\n\tQuoted,\n\tSeparator\n}\n\nexport type Token = WordToken | QuotedToken | SeparatorToken;\n\nexport interface WordToken {\n\treadonly type: TokenType.Parameter;\n\treadonly value: string;\n}\n\nexport interface QuotedToken {\n\treadonly type: TokenType.Quoted;\n\treadonly value: string;\n\treadonly open: string;\n\treadonly close: string;\n}\n\nexport interface SeparatorToken {\n\treadonly type: TokenType.Separator;\n\treadonly value: string;\n}\n","import { QuotedParameter } from './parameters/QuotedParameter';\nimport { WordParameter } from './parameters/WordParameter';\nimport { TokenType, type Token } from './raw/TokenStream';\n\nexport class ParameterStream {\n\tprivate readonly stream: Iterable<Token>;\n\tprivate separators: string[] = [];\n\n\tpublic constructor(stream: Iterable<Token>) {\n\t\tthis.stream = stream;\n\t}\n\n\tpublic *[Symbol.iterator](): Iterator<Parameter, string[]> {\n\t\tfor (const part of this.stream) {\n\t\t\tif (part.type === TokenType.Separator) {\n\t\t\t\tthis.separators.push(part.value);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tyield part.type === TokenType.Quoted ? new QuotedParameter(this.separators, part) : new WordParameter(this.separators, part);\n\t\t\tthis.separators = [];\n\t\t}\n\n\t\treturn this.separators;\n\t}\n}\n\nexport type Parameter = QuotedParameter | WordParameter;\n","import { ParameterStream } from './streams/ParameterStream';\nimport { TokenStream } from './streams/raw/TokenStream';\n\nexport class Lexer {\n\tpublic readonly quotes: readonly [open: string, close: string][];\n\tpublic readonly separator: string;\n\n\tpublic constructor(options: Lexer.Options = {}) {\n\t\tthis.quotes = options.quotes ?? [];\n\t\tthis.separator = options.separator ?? ' ';\n\t}\n\n\tpublic run(input: string) {\n\t\treturn new ParameterStream(this.raw(input));\n\t}\n\n\tpublic raw(input: string) {\n\t\treturn new TokenStream(this, input);\n\t}\n}\n\nexport namespace Lexer {\n\texport interface Options {\n\t\tseparator?: string;\n\t\tquotes?: readonly [open: string, close: string][];\n\t}\n}\n","import type { Parameter } from '../lexer/streams/ParameterStream';\nimport type { Parser } from './Parser';\nimport type { IUnorderedStrategy } from './strategies/IUnorderedStrategy';\n\nexport class ParserResult {\n\tpublic readonly ordered: Parameter[] = [];\n\tpublic readonly flags = new Set<string>();\n\tpublic readonly options = new Map<string, string[]>();\n\tprivate readonly strategy: IUnorderedStrategy;\n\n\tpublic constructor(parser: Parser) {\n\t\tthis.strategy = parser.strategy;\n\t}\n\n\tpublic parse(parameters: Iterable<Parameter>) {\n\t\tfor (const parameter of parameters) {\n\t\t\tthis.parsePossibleFlag(parameter) || this.parsePossibleOptions(parameter) || this.parseOrdered(parameter);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tprivate parsePossibleFlag(parameter: Parameter): boolean {\n\t\treturn this.strategy\n\t\t\t.matchFlag(parameter.value)\n\t\t\t.inspect((value) => this.flags.add(value))\n\t\t\t.isSome();\n\t}\n\n\tprivate parsePossibleOptions(parameter: Parameter): boolean {\n\t\treturn this.strategy\n\t\t\t.matchOption(parameter.value)\n\t\t\t.inspect(([key, value]) => {\n\t\t\t\tconst existing = this.options.get(key);\n\t\t\t\tif (existing) existing.push(value);\n\t\t\t\telse this.options.set(key, [value]);\n\t\t\t})\n\t\t\t.isSome();\n\t}\n\n\tprivate parseOrdered(parameter: Parameter): boolean {\n\t\tthis.ordered.push(parameter);\n\t\treturn true;\n\t}\n}\n","import { Option } from '@sapphire/result';\nimport type { IUnorderedStrategy } from './IUnorderedStrategy';\n\nexport class EmptyStrategy implements IUnorderedStrategy {\n\tpublic matchFlag(): Option<string> {\n\t\treturn Option.none;\n\t}\n\n\tpublic matchOption(): Option<readonly [key: string, value: string]> {\n\t\treturn Option.none;\n\t}\n}\n","import type { Parameter } from '../lexer/streams/ParameterStream';\nimport type { IUnorderedStrategy } from './strategies/IUnorderedStrategy';\nimport { ParserResult } from './ParserResult';\nimport { EmptyStrategy } from './strategies/EmptyStrategy';\n\nexport class Parser {\n\tpublic strategy: IUnorderedStrategy;\n\n\tpublic constructor(strategy?: IUnorderedStrategy) {\n\t\tthis.strategy = strategy ?? new EmptyStrategy();\n\t}\n\n\tpublic setUnorderedStrategy(strategy: IUnorderedStrategy) {\n\t\tthis.strategy = strategy;\n\t\treturn this;\n\t}\n\n\tpublic run(input: Iterable<Parameter>): ParserResult {\n\t\treturn new ParserResult(this).parse(input);\n\t}\n}\n","import { Option } from '@sapphire/result';\nimport type { IUnorderedStrategy } from './IUnorderedStrategy';\n\nexport class PrefixedStrategy implements IUnorderedStrategy {\n\tpublic readonly prefixes: readonly string[];\n\tpublic readonly separators: readonly string[];\n\n\tpublic constructor(prefixes: readonly string[], separators: readonly string[]) {\n\t\tthis.prefixes = prefixes;\n\t\tthis.separators = separators;\n\t}\n\n\tpublic matchFlag(input: string): Option<string> {\n\t\tconst prefix = this.prefixes.find((x) => input.startsWith(x));\n\n\t\t// If the prefix is missing, return None:\n\t\tif (!prefix) return Option.none;\n\n\t\t// If the separator is present, return None:\n\t\tif (this.separators.some((x) => input.includes(x, prefix.length))) return Option.none;\n\n\t\treturn Option.some(input.slice(prefix.length));\n\t}\n\n\tpublic matchOption(input: string): Option<readonly [key: string, value: string]> {\n\t\tconst prefix = this.prefixes.find((x) => input.startsWith(x));\n\n\t\t// If the prefix is missing, return None:\n\t\tif (!prefix) return Option.none;\n\n\t\tfor (const separator of this.separators) {\n\t\t\tconst index = input.indexOf(separator, prefix.length + 1);\n\n\t\t\t// If the separator is missing, skip:\n\t\t\tif (index === -1) continue;\n\n\t\t\t// If the separator is present, but has no value, return None:\n\t\t\tif (index + separator.length === input.length) return Option.none;\n\n\t\t\tconst key = input.slice(prefix.length, index);\n\t\t\tconst value = input.slice(index + separator.length);\n\t\t\treturn Option.some([key, value] as const);\n\t\t}\n\n\t\treturn Option.none;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA+B;AAIxB,IAAM,iBAAN,MAAqB;AAAA,EAI3B,AAAO,YAAY,SAAuB;AAH1C,wBAA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