@wq2/brigadier-ts 1.0.1 → 1.0.3
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/dist/Command.d.ts +2 -2
- package/dist/CommandDispatcher.d.ts +1 -1
- package/dist/ParseResults.d.ts +1 -1
- package/dist/arguments/ArgumentType.d.ts +5 -2
- package/dist/arguments/ArgumentType.js +2 -2
- package/dist/arguments/BoolArgumentType.d.ts +4 -4
- package/dist/arguments/BoolArgumentType.js +3 -5
- package/dist/arguments/FloatArgumentType.d.ts +2 -1
- package/dist/arguments/FloatArgumentType.js +5 -4
- package/dist/arguments/IntegerArgumentType.d.ts +2 -1
- package/dist/arguments/IntegerArgumentType.js +5 -4
- package/dist/arguments/LongArgumentType.d.ts +2 -1
- package/dist/arguments/LongArgumentType.js +5 -4
- package/dist/arguments/NumberArgumentType.d.ts +3 -1
- package/dist/arguments/NumberArgumentType.js +2 -2
- package/dist/arguments/StringArgumentType.d.ts +2 -1
- package/dist/arguments/StringArgumentType.js +2 -2
- package/dist/builder/ArgumentBuilder.d.ts +5 -2
- package/dist/builder/ArgumentBuilder.js +4 -3
- package/dist/builder/LiteralArgumentBuilder.d.ts +3 -2
- package/dist/builder/LiteralArgumentBuilder.js +4 -3
- package/dist/builder/RequiredArgumentBuilder.d.ts +4 -2
- package/dist/builder/RequiredArgumentBuilder.js +4 -3
- package/dist/context/CommandContext.d.ts +8 -3
- package/dist/context/CommandContextBuilder.d.ts +10 -3
- package/dist/context/CommandContextBuilder.js +12 -9
- package/dist/context/ParsedArgument.d.ts +1 -1
- package/dist/context/ParsedArgument.js +2 -2
- package/dist/context/ParsedCommandNode.d.ts +2 -1
- package/dist/context/SuggestionContext.d.ts +1 -1
- package/dist/exceptions/CommandErrorType.d.ts +3 -2
- package/dist/exceptions/CommandErrorType.js +3 -3
- package/dist/exceptions/CommandSyntaxError.d.ts +1 -1
- package/dist/exceptions/CommandSyntaxError.js +23 -23
- package/dist/index.d.ts +18 -18
- package/dist/index.js +18 -18
- package/dist/suggestion/Suggestion.d.ts +1 -1
- package/dist/suggestion/Suggestions.d.ts +2 -1
- package/dist/suggestion/Suggestions.js +3 -3
- package/dist/suggestion/SuggestionsBuilder.d.ts +1 -1
- package/dist/suggestion/SuggestionsBuilder.js +5 -3
- package/dist/tree/ArgumentCommandNode.d.ts +10 -1
- package/dist/tree/ArgumentCommandNode.js +4 -3
- package/dist/tree/CommandNode.d.ts +8 -1
- package/dist/tree/LiteralCommandNode.d.ts +9 -1
- package/dist/tree/LiteralCommandNode.js +8 -5
- package/dist/tree/RootCommandNode.d.ts +6 -1
- package/dist/tree/RootCommandNode.js +4 -3
- package/package.json +1 -1
- package/src/Command.ts +3 -2
- package/src/CommandDispatcher.ts +5 -5
- package/src/ParseResults.ts +1 -1
- package/src/arguments/ArgumentType.ts +5 -7
- package/src/arguments/BoolArgumentType.ts +6 -7
- package/src/arguments/FloatArgumentType.ts +3 -1
- package/src/arguments/IntegerArgumentType.ts +3 -1
- package/src/arguments/LongArgumentType.ts +3 -1
- package/src/arguments/NumberArgumentType.ts +3 -1
- package/src/arguments/StringArgumentType.ts +2 -1
- package/src/builder/ArgumentBuilder.ts +6 -8
- package/src/builder/LiteralArgumentBuilder.ts +3 -2
- package/src/builder/RequiredArgumentBuilder.ts +4 -2
- package/src/context/CommandContext.ts +10 -12
- package/src/context/CommandContextBuilder.ts +12 -14
- package/src/context/ParsedArgument.ts +1 -1
- package/src/context/ParsedCommandNode.ts +2 -1
- package/src/context/SuggestionContext.ts +1 -1
- package/src/exceptions/CommandErrorType.ts +3 -2
- package/src/exceptions/CommandSyntaxError.ts +1 -1
- package/src/index.ts +18 -18
- package/src/suggestion/Suggestion.ts +1 -1
- package/src/suggestion/Suggestions.ts +2 -1
- package/src/suggestion/SuggestionsBuilder.ts +3 -1
- package/src/tree/ArgumentCommandNode.ts +11 -13
- package/src/tree/CommandNode.ts +10 -13
- package/src/tree/LiteralCommandNode.ts +11 -13
- package/src/tree/RootCommandNode.ts +6 -8
- package/test/Arguments.test.ts +3 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { StringReader } from "../StringReader";
|
|
2
|
+
import { CommandSyntaxError } from "./CommandSyntaxError";
|
|
2
3
|
|
|
3
|
-
type CommandErrorFunction = (...args:
|
|
4
|
+
type CommandErrorFunction = <A = unknown>(...args: A[]) => string;
|
|
4
5
|
|
|
5
6
|
export class CommandErrorType {
|
|
6
7
|
private func: CommandErrorFunction;
|
package/src/index.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
export * from "./Command";
|
|
2
|
-
export * from "./Predicate";
|
|
3
|
-
export * from "./context/StringRange";
|
|
4
|
-
export * from "./exceptions/CommandErrorType";
|
|
5
|
-
export * from "./exceptions/CommandSyntaxError";
|
|
6
|
-
export * from "./StringReader";
|
|
7
|
-
export * from "./suggestion/Suggestion";
|
|
8
|
-
export * from "./suggestion/Suggestions";
|
|
9
|
-
export * from "./suggestion/SuggestionsBuilder";
|
|
10
|
-
export * from "./tree/CommandNode";
|
|
11
|
-
export * from "./tree/LiteralCommandNode";
|
|
12
|
-
export * from "./tree/ArgumentCommandNode";
|
|
13
|
-
export * from "./tree/RootCommandNode";
|
|
14
1
|
export * from "./arguments/ArgumentType";
|
|
15
|
-
export * from "./arguments/
|
|
2
|
+
export * from "./arguments/BoolArgumentType";
|
|
16
3
|
export * from "./arguments/FloatArgumentType";
|
|
17
4
|
export * from "./arguments/IntegerArgumentType";
|
|
18
5
|
export * from "./arguments/LongArgumentType";
|
|
19
|
-
export * from "./arguments/
|
|
6
|
+
export * from "./arguments/NumberArgumentType";
|
|
20
7
|
export * from "./arguments/StringArgumentType";
|
|
21
8
|
export * from "./builder/ArgumentBuilder";
|
|
22
9
|
export * from "./builder/LiteralArgumentBuilder";
|
|
23
10
|
export * from "./builder/RequiredArgumentBuilder";
|
|
24
|
-
export * from "./
|
|
25
|
-
export * from "./
|
|
11
|
+
export * from "./Command";
|
|
12
|
+
export * from "./CommandDispatcher";
|
|
26
13
|
export * from "./context/CommandContext";
|
|
27
14
|
export * from "./context/CommandContextBuilder";
|
|
15
|
+
export * from "./context/ParsedArgument";
|
|
16
|
+
export * from "./context/ParsedCommandNode";
|
|
17
|
+
export * from "./context/StringRange";
|
|
28
18
|
export * from "./context/SuggestionContext";
|
|
19
|
+
export * from "./exceptions/CommandErrorType";
|
|
20
|
+
export * from "./exceptions/CommandSyntaxError";
|
|
29
21
|
export * from "./ParseResults";
|
|
30
|
-
export * from "./
|
|
22
|
+
export * from "./Predicate";
|
|
23
|
+
export * from "./StringReader";
|
|
24
|
+
export * from "./suggestion/Suggestion";
|
|
25
|
+
export * from "./suggestion/Suggestions";
|
|
26
|
+
export * from "./suggestion/SuggestionsBuilder";
|
|
27
|
+
export * from "./tree/ArgumentCommandNode";
|
|
28
|
+
export * from "./tree/CommandNode";
|
|
29
|
+
export * from "./tree/LiteralCommandNode";
|
|
30
|
+
export * from "./tree/RootCommandNode";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StringRange } from "../context/StringRange";
|
|
2
|
+
import { Suggestion } from "./Suggestion";
|
|
3
|
+
import { Suggestions } from "./Suggestions";
|
|
2
4
|
|
|
3
5
|
export class SuggestionsBuilder {
|
|
4
6
|
private input: string;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type SuggestionsBuilder,
|
|
13
|
-
} from "..";
|
|
1
|
+
import type { ArgumentType } from "../arguments/ArgumentType";
|
|
2
|
+
import type { RedirectModifier } from "../builder/ArgumentBuilder";
|
|
3
|
+
import type { Command } from "../Command";
|
|
4
|
+
import type { CommandContext } from "../context/CommandContext";
|
|
5
|
+
import type { CommandContextBuilder } from "../context/CommandContextBuilder";
|
|
6
|
+
import { ParsedArgument } from "../context/ParsedArgument";
|
|
7
|
+
import type { Predicate } from "../Predicate";
|
|
8
|
+
import type { StringReader } from "../StringReader";
|
|
9
|
+
import type { Suggestions } from "../suggestion/Suggestions";
|
|
10
|
+
import type { SuggestionsBuilder } from "../suggestion/SuggestionsBuilder";
|
|
11
|
+
import { CommandNode } from "./CommandNode";
|
|
14
12
|
|
|
15
13
|
export class ArgumentCommandNode<S, T> extends CommandNode<S> {
|
|
16
14
|
name: string;
|
package/src/tree/CommandNode.ts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type SuggestionsBuilder,
|
|
11
|
-
type Suggestions,
|
|
12
|
-
} from "..";
|
|
1
|
+
import { ArgumentCommandNode, LiteralCommandNode } from "..";
|
|
2
|
+
import type { RedirectModifier } from "../builder/ArgumentBuilder";
|
|
3
|
+
import type { Command } from "../Command";
|
|
4
|
+
import type { CommandContext } from "../context/CommandContext";
|
|
5
|
+
import type { CommandContextBuilder } from "../context/CommandContextBuilder";
|
|
6
|
+
import type { Predicate } from "../Predicate";
|
|
7
|
+
import type { StringReader } from "../StringReader";
|
|
8
|
+
import type { Suggestions } from "../suggestion/Suggestions";
|
|
9
|
+
import type { SuggestionsBuilder } from "../suggestion/SuggestionsBuilder";
|
|
13
10
|
|
|
14
11
|
export abstract class CommandNode<S> {
|
|
15
12
|
private children: Map<string, CommandNode<S>>;
|
|
16
13
|
private literals: Map<string, LiteralCommandNode<S>>;
|
|
17
|
-
private arguments: Map<string, ArgumentCommandNode<S,
|
|
14
|
+
private arguments: Map<string, ArgumentCommandNode<S, unknown>>;
|
|
18
15
|
private command: Command<S>;
|
|
19
16
|
private requirement: Predicate<S>;
|
|
20
17
|
private redirect: CommandNode<S>;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type SuggestionsBuilder,
|
|
13
|
-
} from "..";
|
|
1
|
+
import type { RedirectModifier } from "../builder/ArgumentBuilder";
|
|
2
|
+
import type { Command } from "../Command";
|
|
3
|
+
import type { CommandContext } from "../context/CommandContext";
|
|
4
|
+
import type { CommandContextBuilder } from "../context/CommandContextBuilder";
|
|
5
|
+
import { StringRange } from "../context/StringRange";
|
|
6
|
+
import { CommandSyntaxError } from "../exceptions/CommandSyntaxError";
|
|
7
|
+
import type { Predicate } from "../Predicate";
|
|
8
|
+
import type { StringReader } from "../StringReader";
|
|
9
|
+
import { Suggestions } from "../suggestion/Suggestions";
|
|
10
|
+
import type { SuggestionsBuilder } from "../suggestion/SuggestionsBuilder";
|
|
11
|
+
import { CommandNode } from "./CommandNode";
|
|
14
12
|
|
|
15
13
|
export class LiteralCommandNode<S> extends CommandNode<S> {
|
|
16
14
|
private literal: string;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
type SuggestionsBuilder,
|
|
8
|
-
} from "..";
|
|
1
|
+
import type { CommandContext } from "../context/CommandContext";
|
|
2
|
+
import type { CommandContextBuilder } from "../context/CommandContextBuilder";
|
|
3
|
+
import type { StringReader } from "../StringReader";
|
|
4
|
+
import { Suggestions } from "../suggestion/Suggestions";
|
|
5
|
+
import type { SuggestionsBuilder } from "../suggestion/SuggestionsBuilder";
|
|
6
|
+
import { CommandNode } from "./CommandNode";
|
|
9
7
|
|
|
10
8
|
export class RootCommandNode<S> extends CommandNode<S> {
|
|
11
9
|
constructor() {
|
package/test/Arguments.test.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
argument,
|
|
3
|
-
bool,
|
|
4
3
|
CommandDispatcher,
|
|
5
4
|
FloatArgumentType,
|
|
6
5
|
IntegerArgumentType,
|
|
7
|
-
literal,
|
|
8
6
|
LongArgumentType,
|
|
7
|
+
literal,
|
|
9
8
|
} from "../src";
|
|
10
9
|
|
|
11
10
|
describe("Arguments", () => {
|
|
@@ -14,7 +13,7 @@ describe("Arguments", () => {
|
|
|
14
13
|
dispatcher.register(
|
|
15
14
|
literal("foo").then(
|
|
16
15
|
argument("bar", new IntegerArgumentType()).executes(
|
|
17
|
-
async (ctx) => ctx.get("bar") * 2,
|
|
16
|
+
async (ctx) => ctx.get<number>("bar") * 2,
|
|
18
17
|
),
|
|
19
18
|
),
|
|
20
19
|
);
|
|
@@ -27,7 +26,7 @@ describe("Arguments", () => {
|
|
|
27
26
|
dispatcher.register(
|
|
28
27
|
literal("foo").then(
|
|
29
28
|
argument("bar", new LongArgumentType()).executes(
|
|
30
|
-
async (ctx) => ctx.get("bar").toString().length,
|
|
29
|
+
async (ctx) => ctx.get<bigint>("bar").toString().length,
|
|
31
30
|
),
|
|
32
31
|
),
|
|
33
32
|
);
|