@jsprismarine/brigadier 0.1.0 → 0.2.1
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/LICENSE +0 -0
- package/README.md +57 -39
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/AmbiguityConsumer.js +0 -0
- package/dist/lib/AmbiguityConsumer.js.map +0 -0
- package/dist/lib/Command.js +0 -0
- package/dist/lib/Command.js.map +0 -0
- package/dist/lib/CommandDispatcher.js +45 -28
- package/dist/lib/CommandDispatcher.js.map +1 -1
- package/dist/lib/ImmutableStringReader.js +0 -0
- package/dist/lib/ImmutableStringReader.js.map +0 -0
- package/dist/lib/LiteralMessage.js +0 -0
- package/dist/lib/LiteralMessage.js.map +0 -0
- package/dist/lib/Message.js +0 -0
- package/dist/lib/Message.js.map +0 -0
- package/dist/lib/ParseResults.js +0 -0
- package/dist/lib/ParseResults.js.map +0 -0
- package/dist/lib/Predicate.js +0 -0
- package/dist/lib/Predicate.js.map +0 -0
- package/dist/lib/RedirectModifier.js +0 -0
- package/dist/lib/RedirectModifier.js.map +0 -0
- package/dist/lib/ResultConsumer.js +0 -0
- package/dist/lib/ResultConsumer.js.map +0 -0
- package/dist/lib/SingleRedirectModifier.js +0 -0
- package/dist/lib/SingleRedirectModifier.js.map +0 -0
- package/dist/lib/StringReader.js +0 -0
- package/dist/lib/StringReader.js.map +0 -0
- package/dist/lib/arguments/ArgumentType.js +1 -1
- package/dist/lib/arguments/ArgumentType.js.map +1 -1
- package/dist/lib/arguments/BoolArgumentType.js +0 -0
- package/dist/lib/arguments/BoolArgumentType.js.map +0 -0
- package/dist/lib/arguments/FloatArgumentType.js +0 -0
- package/dist/lib/arguments/FloatArgumentType.js.map +0 -0
- package/dist/lib/arguments/IntegerArgumentType.js +0 -0
- package/dist/lib/arguments/IntegerArgumentType.js.map +0 -0
- package/dist/lib/arguments/StringArgumentType.js +0 -0
- package/dist/lib/arguments/StringArgumentType.js.map +0 -0
- package/dist/lib/builder/ArgumentBuilder.js +0 -0
- package/dist/lib/builder/ArgumentBuilder.js.map +0 -0
- package/dist/lib/builder/LiteralArgumentBuilder.js +0 -0
- package/dist/lib/builder/LiteralArgumentBuilder.js.map +1 -1
- package/dist/lib/builder/RequiredArgumentBuilder.js +0 -0
- package/dist/lib/builder/RequiredArgumentBuilder.js.map +1 -1
- package/dist/lib/context/CommandContext.js +4 -4
- package/dist/lib/context/CommandContext.js.map +1 -1
- package/dist/lib/context/CommandContextBuilder.js +0 -0
- package/dist/lib/context/CommandContextBuilder.js.map +0 -0
- package/dist/lib/context/ParsedArgument.js +0 -0
- package/dist/lib/context/ParsedArgument.js.map +0 -0
- package/dist/lib/context/ParsedCommandNode.js +0 -0
- package/dist/lib/context/ParsedCommandNode.js.map +0 -0
- package/dist/lib/context/StringRange.js +0 -0
- package/dist/lib/context/StringRange.js.map +0 -0
- package/dist/lib/context/SuggestionContext.js +0 -0
- package/dist/lib/context/SuggestionContext.js.map +0 -0
- package/dist/lib/exceptions/BuiltInExceptionProvider.js +0 -0
- package/dist/lib/exceptions/BuiltInExceptionProvider.js.map +0 -0
- package/dist/lib/exceptions/BuiltInExceptions.js +0 -0
- package/dist/lib/exceptions/BuiltInExceptions.js.map +0 -0
- package/dist/lib/exceptions/CommandExceptionType.js +0 -0
- package/dist/lib/exceptions/CommandExceptionType.js.map +0 -0
- package/dist/lib/exceptions/CommandSyntaxException.js +0 -0
- package/dist/lib/exceptions/CommandSyntaxException.js.map +0 -0
- package/dist/lib/exceptions/DynamicCommandExceptionType.js +0 -0
- package/dist/lib/exceptions/DynamicCommandExceptionType.js.map +0 -0
- package/dist/lib/exceptions/SimpleCommandExceptionType.js +0 -0
- package/dist/lib/exceptions/SimpleCommandExceptionType.js.map +0 -0
- package/dist/lib/suggestion/IntegerSuggestion.js +0 -0
- package/dist/lib/suggestion/IntegerSuggestion.js.map +0 -0
- package/dist/lib/suggestion/Suggestion.js +1 -1
- package/dist/lib/suggestion/Suggestion.js.map +1 -1
- package/dist/lib/suggestion/SuggestionProvider.js +0 -0
- package/dist/lib/suggestion/SuggestionProvider.js.map +0 -0
- package/dist/lib/suggestion/Suggestions.js +1 -1
- package/dist/lib/suggestion/Suggestions.js.map +1 -1
- package/dist/lib/suggestion/SuggestionsBuilder.js +0 -0
- package/dist/lib/suggestion/SuggestionsBuilder.js.map +0 -0
- package/dist/lib/tree/ArgumentCommandNode.js +17 -16
- package/dist/lib/tree/ArgumentCommandNode.js.map +1 -1
- package/dist/lib/tree/CommandNode.js +14 -13
- package/dist/lib/tree/CommandNode.js.map +1 -1
- package/dist/lib/tree/LiteralCommandNode.js +0 -0
- package/dist/lib/tree/LiteralCommandNode.js.map +0 -0
- package/dist/lib/tree/RootCommandNode.js +0 -0
- package/dist/lib/tree/RootCommandNode.js.map +0 -0
- package/dist/lib/util/isEqual.js +0 -0
- package/dist/lib/util/isEqual.js.map +0 -0
- package/index.js +0 -0
- package/package.json +55 -48
- package/.prettierrc +0 -10
- package/.renovaterc +0 -3
- package/CHANGELOG.md +0 -30
- package/dist/index.d.ts +0 -23
- package/dist/lib/AmbiguityConsumer.d.ts +0 -4
- package/dist/lib/Command.d.ts +0 -4
- package/dist/lib/CommandDispatcher.d.ts +0 -29
- package/dist/lib/ImmutableStringReader.d.ts +0 -12
- package/dist/lib/LiteralMessage.d.ts +0 -7
- package/dist/lib/Message.d.ts +0 -3
- package/dist/lib/ParseResults.d.ts +0 -13
- package/dist/lib/Predicate.d.ts +0 -3
- package/dist/lib/Primitive.js +0 -2
- package/dist/lib/RedirectModifier.d.ts +0 -4
- package/dist/lib/ResultConsumer.d.ts +0 -4
- package/dist/lib/SingleRedirectModifier.d.ts +0 -4
- package/dist/lib/StringReader.d.ts +0 -27
- package/dist/lib/arguments/ArgumentType.d.ts +0 -21
- package/dist/lib/arguments/BoolArgumentType.d.ts +0 -13
- package/dist/lib/arguments/FloatArgumentType.d.ts +0 -16
- package/dist/lib/arguments/IntegerArgumentType.d.ts +0 -16
- package/dist/lib/arguments/StringArgumentType.d.ts +0 -21
- package/dist/lib/builder/ArgumentBuilder.d.ts +0 -28
- package/dist/lib/builder/LiteralArgumentBuilder.d.ts +0 -11
- package/dist/lib/builder/RequiredArgumentBuilder.d.ts +0 -18
- package/dist/lib/context/CommandContext.d.ts +0 -33
- package/dist/lib/context/CommandContextBuilder.d.ts +0 -38
- package/dist/lib/context/ParsedArgument.d.ts +0 -9
- package/dist/lib/context/ParsedCommandNode.d.ts +0 -11
- package/dist/lib/context/StringRange.d.ts +0 -16
- package/dist/lib/context/SuggestionContext.d.ts +0 -6
- package/dist/lib/exceptions/BuiltInExceptionProvider.d.ts +0 -23
- package/dist/lib/exceptions/BuiltInExceptions.d.ts +0 -43
- package/dist/lib/exceptions/CommandExceptionType.d.ts +0 -2
- package/dist/lib/exceptions/CommandSyntaxException.d.ts +0 -19
- package/dist/lib/exceptions/Dynamic2CommandExceptionType.js +0 -19
- package/dist/lib/exceptions/DynamicCommandExceptionType.d.ts +0 -10
- package/dist/lib/exceptions/SimpleCommandExceptionType.d.ts +0 -11
- package/dist/lib/suggestion/IntegerSuggestion.d.ts +0 -12
- package/dist/lib/suggestion/Suggestion.d.ts +0 -17
- package/dist/lib/suggestion/SuggestionProvider.d.ts +0 -6
- package/dist/lib/suggestion/Suggestions.d.ts +0 -16
- package/dist/lib/suggestion/SuggestionsBuilder.d.ts +0 -18
- package/dist/lib/tree/ArgumentCommandNode.d.ts +0 -31
- package/dist/lib/tree/CommandNode.d.ts +0 -45
- package/dist/lib/tree/LiteralCommandNode.d.ts +0 -27
- package/dist/lib/tree/RootCommandNode.d.ts +0 -21
- package/dist/lib/util/isEqual.d.ts +0 -1
- package/example/fill.js +0 -47
- package/example/fill.ts +0 -50
- package/src/index.ts +0 -50
- package/src/lib/AmbiguityConsumer.ts +0 -6
- package/src/lib/Command.ts +0 -5
- package/src/lib/CommandDispatcher.ts +0 -390
- package/src/lib/ImmutableStringReader.ts +0 -22
- package/src/lib/LiteralMessage.ts +0 -17
- package/src/lib/Message.ts +0 -3
- package/src/lib/ParseResults.ts +0 -32
- package/src/lib/Predicate.ts +0 -3
- package/src/lib/RedirectModifier.ts +0 -5
- package/src/lib/ResultConsumer.ts +0 -6
- package/src/lib/SingleRedirectModifier.ts +0 -6
- package/src/lib/StringReader.ts +0 -210
- package/src/lib/arguments/ArgumentType.ts +0 -27
- package/src/lib/arguments/BoolArgumentType.ts +0 -41
- package/src/lib/arguments/FloatArgumentType.ts +0 -75
- package/src/lib/arguments/IntegerArgumentType.ts +0 -75
- package/src/lib/arguments/StringArgumentType.ts +0 -83
- package/src/lib/builder/ArgumentBuilder.ts +0 -94
- package/src/lib/builder/LiteralArgumentBuilder.ts +0 -35
- package/src/lib/builder/RequiredArgumentBuilder.ts +0 -54
- package/src/lib/context/CommandContext.ts +0 -118
- package/src/lib/context/CommandContextBuilder.ts +0 -155
- package/src/lib/context/ParsedArgument.ts +0 -27
- package/src/lib/context/ParsedCommandNode.ts +0 -35
- package/src/lib/context/StringRange.ts +0 -57
- package/src/lib/context/SuggestionContext.ts +0 -12
- package/src/lib/exceptions/BuiltInExceptionProvider.ts +0 -43
- package/src/lib/exceptions/BuiltInExceptions.ts +0 -121
- package/src/lib/exceptions/CommandExceptionType.ts +0 -2
- package/src/lib/exceptions/CommandSyntaxException.ts +0 -77
- package/src/lib/exceptions/DynamicCommandExceptionType.ts +0 -22
- package/src/lib/exceptions/SimpleCommandExceptionType.ts +0 -26
- package/src/lib/suggestion/IntegerSuggestion.ts +0 -46
- package/src/lib/suggestion/Suggestion.ts +0 -87
- package/src/lib/suggestion/SuggestionProvider.ts +0 -7
- package/src/lib/suggestion/Suggestions.ts +0 -85
- package/src/lib/suggestion/SuggestionsBuilder.ts +0 -69
- package/src/lib/tree/ArgumentCommandNode.ts +0 -118
- package/src/lib/tree/CommandNode.ts +0 -200
- package/src/lib/tree/LiteralCommandNode.ts +0 -111
- package/src/lib/tree/RootCommandNode.ts +0 -62
- package/src/lib/util/isEqual.ts +0 -75
- package/test/CommandDispatcherTest.ts +0 -427
- package/test/CommandDispatcherUsagesTest.ts +0 -163
- package/test/CommandSuggestionsTest.ts +0 -283
- package/test/StringReaderTest.ts +0 -391
- package/test/arguments/BoolArgumentTypeTest.ts +0 -18
- package/test/arguments/FloatArgumentTypeTest.ts +0 -61
- package/test/arguments/IntegerArgumentTypeTest.ts +0 -63
- package/test/arguments/StringArgumentTypeTest.ts +0 -61
- package/test/benchmarks/ExecuteBenchmark.js +0 -33
- package/test/benchmarks/ParsingBenchmark.js +0 -96
- package/test/builder/ArgumentBuilderTest.ts +0 -61
- package/test/builder/LiteralArgumentBuilderTest.ts +0 -37
- package/test/builder/RequiredArgumentBuilderTest.ts +0 -40
- package/test/context/CommandContextTest.ts +0 -77
- package/test/context/ParsedArgumentTest.ts +0 -19
- package/test/exceptions/DynamicCommandSyntaxExceptionTypeTest.ts +0 -18
- package/test/exceptions/SimpleCommandSyntaxExceptionTypeTest.ts +0 -33
- package/test/suggestion/SuggestionBuilderTest.ts +0 -66
- package/test/suggestion/SuggestionTest.ts +0 -65
- package/test/suggestion/SuggestionsTest.ts +0 -24
- package/test/tree/AbstractCommandNodeTest.ts +0 -57
- package/test/tree/ArgumentCommandNodeTest.ts +0 -81
- package/test/tree/LiteralCommandNodeTest.ts +0 -112
- package/test/tree/RootCommandNodeTest.ts +0 -70
- package/test/utils/testEquality.ts +0 -10
- package/tsconfig.json +0 -40
- package/tsconfig.tsbuildinfo +0 -1578
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import StringReader from "../StringReader";
|
|
2
|
-
import CommandContext from "../context/CommandContext";
|
|
3
|
-
import Suggestions from "../suggestion/Suggestions";
|
|
4
|
-
import SuggestionsBuilder from "../suggestion/SuggestionsBuilder";
|
|
5
|
-
import ArgumentType from "./ArgumentType";
|
|
6
|
-
export default class BoolArgumentType implements ArgumentType<boolean> {
|
|
7
|
-
private constructor();
|
|
8
|
-
static bool(): BoolArgumentType;
|
|
9
|
-
static getBool(context: CommandContext<any>, name: string): boolean;
|
|
10
|
-
parse(reader: StringReader): boolean;
|
|
11
|
-
listSuggestions(context: CommandContext<any>, builder: SuggestionsBuilder): Promise<Suggestions>;
|
|
12
|
-
getExamples(): Iterable<string>;
|
|
13
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import StringReader from "../StringReader";
|
|
2
|
-
import CommandContext from "../context/CommandContext";
|
|
3
|
-
import ArgumentType from "./ArgumentType";
|
|
4
|
-
export default class FloatArgumentType implements ArgumentType<number> {
|
|
5
|
-
private minimum;
|
|
6
|
-
private maximum;
|
|
7
|
-
private constructor();
|
|
8
|
-
static float(min?: number, max?: number): FloatArgumentType;
|
|
9
|
-
static getFloat(context: CommandContext<any>, name: string): number;
|
|
10
|
-
getMinimum(): number;
|
|
11
|
-
getMaximum(): number;
|
|
12
|
-
parse(reader: StringReader): number;
|
|
13
|
-
equals(o: object): boolean;
|
|
14
|
-
toString(): string;
|
|
15
|
-
getExamples(): Iterable<string>;
|
|
16
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import StringReader from "../StringReader";
|
|
2
|
-
import CommandContext from "../context/CommandContext";
|
|
3
|
-
import ArgumentType from "./ArgumentType";
|
|
4
|
-
export default class IntegerArgumentType implements ArgumentType<number> {
|
|
5
|
-
private minimum;
|
|
6
|
-
private maximum;
|
|
7
|
-
private constructor();
|
|
8
|
-
static integer(min?: number, max?: number): IntegerArgumentType;
|
|
9
|
-
static getInteger(context: CommandContext<any>, name: string): number;
|
|
10
|
-
getMinimum(): number;
|
|
11
|
-
getMaximum(): number;
|
|
12
|
-
parse(reader: StringReader): number;
|
|
13
|
-
equals(o: object): boolean;
|
|
14
|
-
toString(): string;
|
|
15
|
-
getExamples(): Iterable<string>;
|
|
16
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import StringReader from "../StringReader";
|
|
2
|
-
import CommandContext from "../context/CommandContext";
|
|
3
|
-
import ArgumentType from "./ArgumentType";
|
|
4
|
-
export declare enum StringType {
|
|
5
|
-
SINGLE_WORD = "words_with_underscores",
|
|
6
|
-
QUOTABLE_PHRASE = "\"quoted phrase\"",
|
|
7
|
-
GREEDY_PHRASE = "words with spaces"
|
|
8
|
-
}
|
|
9
|
-
export default class StringArgumentType implements ArgumentType<string> {
|
|
10
|
-
private type;
|
|
11
|
-
private constructor();
|
|
12
|
-
static word(): StringArgumentType;
|
|
13
|
-
static string(): StringArgumentType;
|
|
14
|
-
static greedyString(): StringArgumentType;
|
|
15
|
-
static getString(context: CommandContext<any>, name: string): string;
|
|
16
|
-
getType(): StringType;
|
|
17
|
-
parse(reader: StringReader): string;
|
|
18
|
-
toString(): string;
|
|
19
|
-
static escapeIfRequired(input: string): String;
|
|
20
|
-
private static escape;
|
|
21
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import Command from "../Command";
|
|
2
|
-
import RedirectModifier from "../RedirectModifier";
|
|
3
|
-
import SingleRedirectModifier from "../SingleRedirectModifier";
|
|
4
|
-
import CommandNode from "../tree/CommandNode";
|
|
5
|
-
import Predicate from "../Predicate";
|
|
6
|
-
declare abstract class ArgumentBuilder<S, T extends ArgumentBuilder<S, T>> {
|
|
7
|
-
private args;
|
|
8
|
-
private command;
|
|
9
|
-
private requirement;
|
|
10
|
-
private target;
|
|
11
|
-
private modifier;
|
|
12
|
-
private forks;
|
|
13
|
-
abstract getThis(): T;
|
|
14
|
-
then(arg: ArgumentBuilder<S, any> | CommandNode<S>): T;
|
|
15
|
-
getArguments(): Iterable<CommandNode<S>>;
|
|
16
|
-
executes(command: Command<S>): T;
|
|
17
|
-
getCommand(): Command<S>;
|
|
18
|
-
requires(requirement: Predicate<S>): T;
|
|
19
|
-
getRequirement(): Predicate<S>;
|
|
20
|
-
redirect(target: CommandNode<S>, modifier?: SingleRedirectModifier<S>): T;
|
|
21
|
-
fork(target: CommandNode<S>, modifier: RedirectModifier<S>): T;
|
|
22
|
-
forward(target: CommandNode<S>, modifier: RedirectModifier<S>, fork: boolean): T;
|
|
23
|
-
getRedirect(): CommandNode<S>;
|
|
24
|
-
getRedirectModifier(): RedirectModifier<S>;
|
|
25
|
-
isFork(): boolean;
|
|
26
|
-
abstract build(): CommandNode<S>;
|
|
27
|
-
}
|
|
28
|
-
export default ArgumentBuilder;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import LiteralCommandNode from "../tree/LiteralCommandNode";
|
|
2
|
-
import ArgumentBuilder from "./ArgumentBuilder";
|
|
3
|
-
export default class LiteralArgumentBuilder<S> extends ArgumentBuilder<S, LiteralArgumentBuilder<S>> {
|
|
4
|
-
private literal;
|
|
5
|
-
constructor(literal: string);
|
|
6
|
-
static literal<S>(name: string): LiteralArgumentBuilder<S>;
|
|
7
|
-
getThis(): LiteralArgumentBuilder<S>;
|
|
8
|
-
getLiteral(): string;
|
|
9
|
-
build(): LiteralCommandNode<S>;
|
|
10
|
-
}
|
|
11
|
-
export declare const literal: typeof LiteralArgumentBuilder.literal;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import ArgumentType from "../arguments/ArgumentType";
|
|
2
|
-
import SuggestionProvider from "../suggestion/SuggestionProvider";
|
|
3
|
-
import ArgumentCommandNode from "../tree/ArgumentCommandNode";
|
|
4
|
-
import ArgumentBuilder from "./ArgumentBuilder";
|
|
5
|
-
export default class RequiredArgumentBuilder<S, T> extends ArgumentBuilder<S, RequiredArgumentBuilder<S, T>> {
|
|
6
|
-
private name;
|
|
7
|
-
private type;
|
|
8
|
-
private suggestionsProvider;
|
|
9
|
-
private constructor();
|
|
10
|
-
static argument<S, T>(name: string, type: ArgumentType<T>): RequiredArgumentBuilder<S, T>;
|
|
11
|
-
suggests(provider: SuggestionProvider<S>): RequiredArgumentBuilder<S, T>;
|
|
12
|
-
getSuggestionsProvider(): SuggestionProvider<S>;
|
|
13
|
-
getThis(): RequiredArgumentBuilder<S, T>;
|
|
14
|
-
getType(): ArgumentType<T>;
|
|
15
|
-
getName(): string;
|
|
16
|
-
build(): ArgumentCommandNode<S, T>;
|
|
17
|
-
}
|
|
18
|
-
export declare const argument: typeof RequiredArgumentBuilder.argument;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import Command from "../Command";
|
|
2
|
-
import RedirectModifier from "../RedirectModifier";
|
|
3
|
-
import CommandNode from "../tree/CommandNode";
|
|
4
|
-
import StringRange from "./StringRange";
|
|
5
|
-
import ParsedArgument from "./ParsedArgument";
|
|
6
|
-
import ParsedCommandNode from "./ParsedCommandNode";
|
|
7
|
-
export default class CommandContext<S> {
|
|
8
|
-
private source;
|
|
9
|
-
private input;
|
|
10
|
-
private command;
|
|
11
|
-
private args;
|
|
12
|
-
private rootNode;
|
|
13
|
-
private nodes;
|
|
14
|
-
private range;
|
|
15
|
-
private child;
|
|
16
|
-
private modifier;
|
|
17
|
-
private forks;
|
|
18
|
-
constructor(source: S, input: string, args: Map<String, ParsedArgument<S, any>>, command: Command<S>, rootNode: CommandNode<S>, nodes: Array<ParsedCommandNode<S>>, range: StringRange, child: CommandContext<S>, modifier: RedirectModifier<S>, forks: boolean);
|
|
19
|
-
copyFor(source: S): CommandContext<S>;
|
|
20
|
-
getChild(): CommandContext<S>;
|
|
21
|
-
getLastChild(): CommandContext<S>;
|
|
22
|
-
getCommand(): Command<S>;
|
|
23
|
-
getSource(): S;
|
|
24
|
-
getArgument(name: string, clazz?: Function): any;
|
|
25
|
-
equals(o: object): boolean;
|
|
26
|
-
getRedirectModifier(): RedirectModifier<S>;
|
|
27
|
-
getRange(): StringRange;
|
|
28
|
-
getInput(): string;
|
|
29
|
-
getRootNode(): CommandNode<S>;
|
|
30
|
-
getNodes(): Array<ParsedCommandNode<S>>;
|
|
31
|
-
hasNodes(): boolean;
|
|
32
|
-
isForked(): boolean;
|
|
33
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import Command from "../Command";
|
|
2
|
-
import StringRange from "./StringRange";
|
|
3
|
-
import CommandNode from "../tree/CommandNode";
|
|
4
|
-
import CommandContext from "./CommandContext";
|
|
5
|
-
import ParsedArgument from "./ParsedArgument";
|
|
6
|
-
import SuggestionContext from "./SuggestionContext";
|
|
7
|
-
import ParsedCommandNode from "./ParsedCommandNode";
|
|
8
|
-
import CommandDispatcher from "../CommandDispatcher";
|
|
9
|
-
export default class CommandContextBuilder<S> {
|
|
10
|
-
private args;
|
|
11
|
-
private rootNode;
|
|
12
|
-
private nodes;
|
|
13
|
-
private dispatcher;
|
|
14
|
-
private source;
|
|
15
|
-
private command;
|
|
16
|
-
private child;
|
|
17
|
-
private range;
|
|
18
|
-
private modifier;
|
|
19
|
-
private forks;
|
|
20
|
-
constructor(dispatcher: CommandDispatcher<S>, source: S, rootNode: CommandNode<S>, start: number);
|
|
21
|
-
withSource(source: S): CommandContextBuilder<S>;
|
|
22
|
-
getSource(): S;
|
|
23
|
-
getRootNode(): CommandNode<S>;
|
|
24
|
-
withArgument(name: String, argument: ParsedArgument<S, any>): CommandContextBuilder<S>;
|
|
25
|
-
getArguments(): Map<String, ParsedArgument<S, any>>;
|
|
26
|
-
withCommand(command: Command<S>): CommandContextBuilder<S>;
|
|
27
|
-
withNode(node: CommandNode<S>, range: StringRange): CommandContextBuilder<S>;
|
|
28
|
-
copy(): CommandContextBuilder<S>;
|
|
29
|
-
withChild(child: CommandContextBuilder<S>): CommandContextBuilder<S>;
|
|
30
|
-
getChild(): CommandContextBuilder<S>;
|
|
31
|
-
getLastChild(): CommandContextBuilder<S>;
|
|
32
|
-
getCommand(): Command<S>;
|
|
33
|
-
getNodes(): Array<ParsedCommandNode<S>>;
|
|
34
|
-
build(input: string): CommandContext<S>;
|
|
35
|
-
getDispatcher(): CommandDispatcher<S>;
|
|
36
|
-
getRange(): StringRange;
|
|
37
|
-
findSuggestionContext(cursor: number): SuggestionContext<S>;
|
|
38
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import CommandNode from "../tree/CommandNode";
|
|
2
|
-
import StringRange from "./StringRange";
|
|
3
|
-
export default class ParsedCommandNode<S> {
|
|
4
|
-
private node;
|
|
5
|
-
private range;
|
|
6
|
-
constructor(node: CommandNode<S>, range: StringRange);
|
|
7
|
-
getNode(): CommandNode<S>;
|
|
8
|
-
getRange(): StringRange;
|
|
9
|
-
toString(): String;
|
|
10
|
-
equals(o: object): boolean;
|
|
11
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import ImmutableStringReader from "../ImmutableStringReader";
|
|
2
|
-
export default class StringRange {
|
|
3
|
-
private start;
|
|
4
|
-
private end;
|
|
5
|
-
constructor(start: number, end: number);
|
|
6
|
-
static at(pos: number): StringRange;
|
|
7
|
-
static between(start: number, end: number): StringRange;
|
|
8
|
-
static encompassing(a: StringRange, b: StringRange): StringRange;
|
|
9
|
-
getStart(): number;
|
|
10
|
-
getEnd(): number;
|
|
11
|
-
get(str: ImmutableStringReader | string): string;
|
|
12
|
-
isEmpty(): boolean;
|
|
13
|
-
getLength(): number;
|
|
14
|
-
equals(o: object): boolean;
|
|
15
|
-
toString(): string;
|
|
16
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import DynamicCommandExceptionType from "./DynamicCommandExceptionType";
|
|
2
|
-
import SimpleCommandExceptionType from "./SimpleCommandExceptionType";
|
|
3
|
-
export default interface BuiltInExceptionProvider {
|
|
4
|
-
floatTooLow(): DynamicCommandExceptionType;
|
|
5
|
-
floatTooHigh(): DynamicCommandExceptionType;
|
|
6
|
-
integerTooLow(): DynamicCommandExceptionType;
|
|
7
|
-
integerTooHigh(): DynamicCommandExceptionType;
|
|
8
|
-
literalIncorrect(): DynamicCommandExceptionType;
|
|
9
|
-
readerExpectedStartOfQuote(): SimpleCommandExceptionType;
|
|
10
|
-
readerExpectedEndOfQuote(): SimpleCommandExceptionType;
|
|
11
|
-
readerInvalidEscape(): DynamicCommandExceptionType;
|
|
12
|
-
readerInvalidBool(): DynamicCommandExceptionType;
|
|
13
|
-
readerInvalidInt(): DynamicCommandExceptionType;
|
|
14
|
-
readerExpectedInt(): SimpleCommandExceptionType;
|
|
15
|
-
readerInvalidFloat(): DynamicCommandExceptionType;
|
|
16
|
-
readerExpectedFloat(): SimpleCommandExceptionType;
|
|
17
|
-
readerExpectedBool(): SimpleCommandExceptionType;
|
|
18
|
-
readerExpectedSymbol(): DynamicCommandExceptionType;
|
|
19
|
-
dispatcherUnknownCommand(): SimpleCommandExceptionType;
|
|
20
|
-
dispatcherUnknownArgument(): SimpleCommandExceptionType;
|
|
21
|
-
dispatcherExpectedArgumentSeparator(): SimpleCommandExceptionType;
|
|
22
|
-
dispatcherParseException(): DynamicCommandExceptionType;
|
|
23
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import BuiltInExceptionProvider from "./BuiltInExceptionProvider";
|
|
2
|
-
import SimpleCommandExceptionType from "./SimpleCommandExceptionType";
|
|
3
|
-
import DynamicCommandExceptionType from "./DynamicCommandExceptionType";
|
|
4
|
-
export default class BuiltInExceptions implements BuiltInExceptionProvider {
|
|
5
|
-
private static FLOAT_TOO_SMALL;
|
|
6
|
-
private static FLOAT_TOO_BIG;
|
|
7
|
-
private static INTEGER_TOO_SMALL;
|
|
8
|
-
private static INTEGER_TOO_BIG;
|
|
9
|
-
private static LITERAL_INCORRECT;
|
|
10
|
-
private static READER_EXPECTED_START_OF_QUOTE;
|
|
11
|
-
private static READER_EXPECTED_END_OF_QUOTE;
|
|
12
|
-
private static READER_INVALID_ESCAPE;
|
|
13
|
-
private static READER_INVALID_BOOL;
|
|
14
|
-
private static READER_INVALID_INT;
|
|
15
|
-
private static READER_EXPECTED_INT;
|
|
16
|
-
private static READER_INVALID_FLOAT;
|
|
17
|
-
private static READER_EXPECTED_FLOAT;
|
|
18
|
-
private static READER_EXPECTED_BOOL;
|
|
19
|
-
private static READER_EXPECTED_SYMBOL;
|
|
20
|
-
private static DISPATCHER_UNKNOWN_COMMAND;
|
|
21
|
-
private static DISPATCHER_UNKNOWN_ARGUMENT;
|
|
22
|
-
private static DISPATCHER_EXPECTED_ARGUMENT_SEPARATOR;
|
|
23
|
-
private static DISPATCHER_PARSE_EXCEPTION;
|
|
24
|
-
floatTooLow(): DynamicCommandExceptionType;
|
|
25
|
-
floatTooHigh(): DynamicCommandExceptionType;
|
|
26
|
-
integerTooLow(): DynamicCommandExceptionType;
|
|
27
|
-
integerTooHigh(): DynamicCommandExceptionType;
|
|
28
|
-
literalIncorrect(): DynamicCommandExceptionType;
|
|
29
|
-
readerExpectedStartOfQuote(): SimpleCommandExceptionType;
|
|
30
|
-
readerExpectedEndOfQuote(): SimpleCommandExceptionType;
|
|
31
|
-
readerInvalidEscape(): DynamicCommandExceptionType;
|
|
32
|
-
readerInvalidBool(): DynamicCommandExceptionType;
|
|
33
|
-
readerInvalidInt(): DynamicCommandExceptionType;
|
|
34
|
-
readerExpectedInt(): SimpleCommandExceptionType;
|
|
35
|
-
readerInvalidFloat(): DynamicCommandExceptionType;
|
|
36
|
-
readerExpectedFloat(): SimpleCommandExceptionType;
|
|
37
|
-
readerExpectedBool(): SimpleCommandExceptionType;
|
|
38
|
-
readerExpectedSymbol(): DynamicCommandExceptionType;
|
|
39
|
-
dispatcherUnknownCommand(): SimpleCommandExceptionType;
|
|
40
|
-
dispatcherUnknownArgument(): SimpleCommandExceptionType;
|
|
41
|
-
dispatcherExpectedArgumentSeparator(): SimpleCommandExceptionType;
|
|
42
|
-
dispatcherParseException(): DynamicCommandExceptionType;
|
|
43
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import Message from "../Message";
|
|
2
|
-
import BuiltInExceptionProvider from "./BuiltInExceptionProvider";
|
|
3
|
-
import CommandExceptionType from "./CommandExceptionType";
|
|
4
|
-
export default class CommandSyntaxException extends Error {
|
|
5
|
-
static CONTEXT_AMOUNT: number;
|
|
6
|
-
static BUILT_IN_EXCEPTIONS: BuiltInExceptionProvider;
|
|
7
|
-
private type;
|
|
8
|
-
private __message;
|
|
9
|
-
private input;
|
|
10
|
-
private cursor;
|
|
11
|
-
constructor(type: CommandExceptionType, message: Message, input?: string, cursor?: number);
|
|
12
|
-
getMessage(): string;
|
|
13
|
-
getRawMessage(): Message;
|
|
14
|
-
getContext(): string;
|
|
15
|
-
getType(): CommandExceptionType;
|
|
16
|
-
getInput(): string;
|
|
17
|
-
getCursor(): number;
|
|
18
|
-
toString(): string;
|
|
19
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const CommandSyntaxException_1 = __importDefault(require("./CommandSyntaxException"));
|
|
7
|
-
class Dynamic2CommandExceptionType {
|
|
8
|
-
constructor(fn) {
|
|
9
|
-
this.fn = fn;
|
|
10
|
-
Error.captureStackTrace(this, Dynamic2CommandExceptionType);
|
|
11
|
-
}
|
|
12
|
-
create(a, b) {
|
|
13
|
-
return new CommandSyntaxException_1.default(this, this.fn(a, b));
|
|
14
|
-
}
|
|
15
|
-
createWithContext(reader, a, b) {
|
|
16
|
-
return new CommandSyntaxException_1.default(this, this.fn(a, b), reader.getString(), reader.getCursor());
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.default = Dynamic2CommandExceptionType;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import Message from "../Message";
|
|
2
|
-
import CommandExceptionType from "./CommandExceptionType";
|
|
3
|
-
import CommandSyntaxException from "./CommandSyntaxException";
|
|
4
|
-
import ImmutableStringReader from "../ImmutableStringReader";
|
|
5
|
-
export default class DynamicCommandExceptionType implements CommandExceptionType {
|
|
6
|
-
private fn;
|
|
7
|
-
constructor(fn: (...args: any[]) => Message);
|
|
8
|
-
create(...args: any[]): CommandSyntaxException;
|
|
9
|
-
createWithContext(reader: ImmutableStringReader, ...args: any[]): CommandSyntaxException;
|
|
10
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import Message from "../Message";
|
|
2
|
-
import ImmutableStringReader from "../ImmutableStringReader";
|
|
3
|
-
import CommandExceptionType from "./CommandExceptionType";
|
|
4
|
-
import CommandSyntaxException from "./CommandSyntaxException";
|
|
5
|
-
export default class SimpleCommandExceptionType implements CommandExceptionType {
|
|
6
|
-
private message;
|
|
7
|
-
constructor(message: Message);
|
|
8
|
-
create(): CommandSyntaxException;
|
|
9
|
-
createWithContext(reader: ImmutableStringReader): CommandSyntaxException;
|
|
10
|
-
toString(): string;
|
|
11
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Message from "../Message";
|
|
2
|
-
import StringRange from "../context/StringRange";
|
|
3
|
-
import Suggestion from "./Suggestion";
|
|
4
|
-
export default class IntegerSuggestion extends Suggestion {
|
|
5
|
-
private value;
|
|
6
|
-
constructor(range: StringRange, value: number, tooltip?: Message);
|
|
7
|
-
getValue(): number;
|
|
8
|
-
equals(o: object): boolean;
|
|
9
|
-
toString(): String;
|
|
10
|
-
compareTo(o: Suggestion): number;
|
|
11
|
-
compareToIgnoreCase(b: Suggestion): number;
|
|
12
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Message from "../Message";
|
|
2
|
-
import StringRange from "../context/StringRange";
|
|
3
|
-
export default class Suggestion {
|
|
4
|
-
private range;
|
|
5
|
-
private text;
|
|
6
|
-
private tooltip;
|
|
7
|
-
constructor(range: StringRange, text: string, tooltip?: Message);
|
|
8
|
-
getRange(): StringRange;
|
|
9
|
-
getText(): string;
|
|
10
|
-
getTooltip(): Message;
|
|
11
|
-
apply(input: string): string;
|
|
12
|
-
equals(o: object): boolean;
|
|
13
|
-
toString(): String;
|
|
14
|
-
compareTo(o: Suggestion): number;
|
|
15
|
-
compareToIgnoreCase(b: Suggestion): number;
|
|
16
|
-
expand(command: string, range: StringRange): Suggestion;
|
|
17
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import Suggestions from "./Suggestions";
|
|
2
|
-
import SuggestionsBuilder from "./SuggestionsBuilder";
|
|
3
|
-
import CommandContext from "../context/CommandContext";
|
|
4
|
-
export default interface SuggestionProvider<S> {
|
|
5
|
-
getSuggestions(context: CommandContext<S>, builder: SuggestionsBuilder): Promise<Suggestions>;
|
|
6
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import StringRange from "../context/StringRange";
|
|
2
|
-
import Suggestion from "./Suggestion";
|
|
3
|
-
export default class Suggestions {
|
|
4
|
-
private static EMPTY;
|
|
5
|
-
private range;
|
|
6
|
-
private suggestions;
|
|
7
|
-
constructor(range: StringRange, suggestions: Array<Suggestion>);
|
|
8
|
-
getRange(): StringRange;
|
|
9
|
-
getList(): Array<Suggestion>;
|
|
10
|
-
isEmpty(): boolean;
|
|
11
|
-
equals(o: object): boolean;
|
|
12
|
-
toString(): String;
|
|
13
|
-
static empty(): Promise<Suggestions>;
|
|
14
|
-
static merge(command: string, input: Array<Suggestions>): Suggestions;
|
|
15
|
-
static create(command: string, suggestions: Array<Suggestion>): Suggestions;
|
|
16
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import Message from "../Message";
|
|
2
|
-
import Suggestions from "./Suggestions";
|
|
3
|
-
export default class SuggestionsBuilder {
|
|
4
|
-
private input;
|
|
5
|
-
private start;
|
|
6
|
-
private remaining;
|
|
7
|
-
private result;
|
|
8
|
-
constructor(input: string, start: number);
|
|
9
|
-
getInput(): String;
|
|
10
|
-
getStart(): number;
|
|
11
|
-
getRemaining(): string;
|
|
12
|
-
build(): Suggestions;
|
|
13
|
-
buildPromise(): Promise<Suggestions>;
|
|
14
|
-
suggest(text: string | number, tooltip?: Message): SuggestionsBuilder;
|
|
15
|
-
add(other: SuggestionsBuilder): SuggestionsBuilder;
|
|
16
|
-
createOffset(start: number): SuggestionsBuilder;
|
|
17
|
-
restart(): SuggestionsBuilder;
|
|
18
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import Command from "../Command";
|
|
2
|
-
import Predicate from "../Predicate";
|
|
3
|
-
import RedirectModifier from "../RedirectModifier";
|
|
4
|
-
import StringReader from "../StringReader";
|
|
5
|
-
import ArgumentType from "../arguments/ArgumentType";
|
|
6
|
-
import RequiredArgumentBuilder from "../builder/RequiredArgumentBuilder";
|
|
7
|
-
import CommandContext from "../context/CommandContext";
|
|
8
|
-
import CommandContextBuilder from "../context/CommandContextBuilder";
|
|
9
|
-
import Suggestions from "../suggestion/Suggestions";
|
|
10
|
-
import SuggestionProvider from "../suggestion/SuggestionProvider";
|
|
11
|
-
import SuggestionsBuilder from "../suggestion/SuggestionsBuilder";
|
|
12
|
-
import CommandNode from "./CommandNode";
|
|
13
|
-
export default class ArgumentCommandNode<S, T> extends CommandNode<S> {
|
|
14
|
-
private name;
|
|
15
|
-
private type;
|
|
16
|
-
private customSuggestions;
|
|
17
|
-
constructor(name: string, type: ArgumentType<T>, command: Command<S>, requirement: Predicate<S>, redirect: CommandNode<S>, modifier: RedirectModifier<S>, forks: boolean, customSuggestions: SuggestionProvider<S>);
|
|
18
|
-
getNodeType(): string;
|
|
19
|
-
getType(): ArgumentType<T>;
|
|
20
|
-
getName(): string;
|
|
21
|
-
getUsageText(): string;
|
|
22
|
-
getCustomSuggestions(): SuggestionProvider<S>;
|
|
23
|
-
parse(reader: StringReader, contextBuilder: CommandContextBuilder<S>): void;
|
|
24
|
-
listSuggestions(context: CommandContext<S>, builder: SuggestionsBuilder): Promise<Suggestions>;
|
|
25
|
-
createBuilder(): RequiredArgumentBuilder<S, T>;
|
|
26
|
-
isValidInput(input: string): boolean;
|
|
27
|
-
equals(o: object): boolean;
|
|
28
|
-
getSortedKey(): string;
|
|
29
|
-
getExamples(): Iterable<string>;
|
|
30
|
-
toString(): string;
|
|
31
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import Predicate from "../Predicate";
|
|
2
|
-
import AmbiguityConsumer from "../AmbiguityConsumer";
|
|
3
|
-
import Command from "../Command";
|
|
4
|
-
import RedirectModifier from "../RedirectModifier";
|
|
5
|
-
import StringReader from "../StringReader";
|
|
6
|
-
import ArgumentBuilder from "../builder/ArgumentBuilder";
|
|
7
|
-
import CommandContext from "../context/CommandContext";
|
|
8
|
-
import CommandContextBuilder from "../context/CommandContextBuilder";
|
|
9
|
-
import Suggestions from "../suggestion/Suggestions";
|
|
10
|
-
import SuggestionsBuilder from "../suggestion/SuggestionsBuilder";
|
|
11
|
-
declare abstract class CommandNode<S> {
|
|
12
|
-
private children;
|
|
13
|
-
private literals;
|
|
14
|
-
private args;
|
|
15
|
-
private requirement;
|
|
16
|
-
private redirect;
|
|
17
|
-
private modifier;
|
|
18
|
-
private forks;
|
|
19
|
-
private command;
|
|
20
|
-
abstract getNodeType(): string;
|
|
21
|
-
constructor(command: Command<S>, requirement: Predicate<S>, redirect: CommandNode<S>, modifier: RedirectModifier<S>, forks: boolean);
|
|
22
|
-
getCommand(): Command<S>;
|
|
23
|
-
getChildren(): IterableIterator<CommandNode<S>>;
|
|
24
|
-
getChildrenCount(): number;
|
|
25
|
-
getChild(name: string): CommandNode<S>;
|
|
26
|
-
getRedirect(): CommandNode<S>;
|
|
27
|
-
getRedirectModifier(): RedirectModifier<S>;
|
|
28
|
-
canUse(source: S): boolean;
|
|
29
|
-
addChild(node: CommandNode<S>): void;
|
|
30
|
-
findAmbiguities(consumer: AmbiguityConsumer<S>): void;
|
|
31
|
-
abstract isValidInput(input: string): boolean;
|
|
32
|
-
equals(o: object): boolean;
|
|
33
|
-
getRequirement(): Predicate<S>;
|
|
34
|
-
abstract getName(): string;
|
|
35
|
-
abstract getUsageText(): string;
|
|
36
|
-
abstract parse(reader: StringReader, contextBuilder: CommandContextBuilder<S>): void;
|
|
37
|
-
abstract listSuggestions(context: CommandContext<S>, builder: SuggestionsBuilder): Promise<Suggestions>;
|
|
38
|
-
abstract createBuilder(): ArgumentBuilder<S, any>;
|
|
39
|
-
abstract getSortedKey(): string;
|
|
40
|
-
getRelevantNodes(input: StringReader): Iterable<CommandNode<S>>;
|
|
41
|
-
compareTo(o: CommandNode<S>): number;
|
|
42
|
-
isFork(): boolean;
|
|
43
|
-
abstract getExamples(): Iterable<string>;
|
|
44
|
-
}
|
|
45
|
-
export default CommandNode;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import Command from "../Command";
|
|
2
|
-
import CommandNode from "./CommandNode";
|
|
3
|
-
import Predicate from "../Predicate";
|
|
4
|
-
import RedirectModifier from "../RedirectModifier";
|
|
5
|
-
import StringReader from "../StringReader";
|
|
6
|
-
import LiteralArgumentBuilder from "../builder/LiteralArgumentBuilder";
|
|
7
|
-
import CommandContext from "../context/CommandContext";
|
|
8
|
-
import CommandContextBuilder from "../context/CommandContextBuilder";
|
|
9
|
-
import Suggestions from "../suggestion/Suggestions";
|
|
10
|
-
import SuggestionsBuilder from "../suggestion/SuggestionsBuilder";
|
|
11
|
-
export default class LiteralCommandNode<S> extends CommandNode<S> {
|
|
12
|
-
private literal;
|
|
13
|
-
constructor(literal: string, command: Command<S>, requirement: Predicate<S>, redirect: CommandNode<S>, modifier: RedirectModifier<S>, forks: boolean);
|
|
14
|
-
getNodeType(): string;
|
|
15
|
-
getLiteral(): string;
|
|
16
|
-
getName(): string;
|
|
17
|
-
parse(reader: StringReader, contextBuilder: CommandContextBuilder<S>): void;
|
|
18
|
-
private __parse;
|
|
19
|
-
listSuggestions(context: CommandContext<S>, builder: SuggestionsBuilder): Promise<Suggestions>;
|
|
20
|
-
isValidInput(input: string): boolean;
|
|
21
|
-
equals(o: object): boolean;
|
|
22
|
-
getUsageText(): string;
|
|
23
|
-
createBuilder(): LiteralArgumentBuilder<S>;
|
|
24
|
-
getSortedKey(): string;
|
|
25
|
-
getExamples(): Iterable<string>;
|
|
26
|
-
toString(): string;
|
|
27
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import CommandNode from "./CommandNode";
|
|
2
|
-
import StringReader from "../StringReader";
|
|
3
|
-
import ArgumentBuilder from "../builder/ArgumentBuilder";
|
|
4
|
-
import CommandContext from "../context/CommandContext";
|
|
5
|
-
import CommandContextBuilder from "../context/CommandContextBuilder";
|
|
6
|
-
import Suggestions from "../suggestion/Suggestions";
|
|
7
|
-
import SuggestionsBuilder from "../suggestion/SuggestionsBuilder";
|
|
8
|
-
export default class RootCommandNode<S> extends CommandNode<S> {
|
|
9
|
-
constructor();
|
|
10
|
-
getNodeType(): string;
|
|
11
|
-
getName(): string;
|
|
12
|
-
getUsageText(): string;
|
|
13
|
-
parse(reader: StringReader, contextBuilder: CommandContextBuilder<S>): void;
|
|
14
|
-
listSuggestions(context: CommandContext<S>, builder: SuggestionsBuilder): Promise<Suggestions>;
|
|
15
|
-
isValidInput(input: String): boolean;
|
|
16
|
-
equals(o: object): boolean;
|
|
17
|
-
createBuilder(): ArgumentBuilder<S, any>;
|
|
18
|
-
getSortedKey(): string;
|
|
19
|
-
getExamples(): Iterable<string>;
|
|
20
|
-
toString(): string;
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function isEqual(a: any, b: any): boolean;
|
package/example/fill.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
const { CommandDispatcher, literal, argument, string, Suggestions } = require("../dist")
|
|
2
|
-
|
|
3
|
-
class BlockPos {
|
|
4
|
-
constructor(x = 0, y = 0, z = 0) {
|
|
5
|
-
this.x = x; this.y = y; this.z = z;
|
|
6
|
-
}
|
|
7
|
-
parse(reader) {
|
|
8
|
-
this.x = reader.readInt();
|
|
9
|
-
reader.skip();
|
|
10
|
-
this.y = reader.readInt();
|
|
11
|
-
reader.skip();
|
|
12
|
-
this.z = reader.readInt();
|
|
13
|
-
return this;
|
|
14
|
-
}
|
|
15
|
-
listSuggestions(context, builder) {
|
|
16
|
-
return Suggestions.empty();
|
|
17
|
-
}
|
|
18
|
-
getExamples() {
|
|
19
|
-
return [
|
|
20
|
-
"1 2 3"
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const dispatcher = new CommandDispatcher();
|
|
26
|
-
|
|
27
|
-
dispatcher.register(
|
|
28
|
-
literal("fill").then(
|
|
29
|
-
argument("pos1", new BlockPos()).then(
|
|
30
|
-
argument("pos2", new BlockPos()).then(
|
|
31
|
-
argument("block", string()).executes(context => {
|
|
32
|
-
console.log(context.getArgument("pos1", BlockPos))
|
|
33
|
-
console.log(context.getArgument("pos2", BlockPos))
|
|
34
|
-
console.log(context.getArgument("block", /*String*/ 3))
|
|
35
|
-
return 0;
|
|
36
|
-
})
|
|
37
|
-
)
|
|
38
|
-
)
|
|
39
|
-
)
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
const parsedCommand = dispatcher.parse("fill 3 4 5 10 11 12 air", {})
|
|
43
|
-
try {
|
|
44
|
-
dispatcher.execute(parsedCommand);
|
|
45
|
-
} catch (ex) {
|
|
46
|
-
console.error(ex.getMessage());
|
|
47
|
-
}
|