@wq2/brigadier-ts 1.0.2 → 1.0.4

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.
Files changed (87) hide show
  1. package/README.md +4 -3
  2. package/dist/Command.d.ts +1 -1
  3. package/dist/CommandDispatcher.d.ts +1 -1
  4. package/dist/ParseResults.d.ts +1 -1
  5. package/dist/arguments/ArgumentType.d.ts +5 -2
  6. package/dist/arguments/ArgumentType.js +2 -2
  7. package/dist/arguments/BoolArgumentType.d.ts +4 -4
  8. package/dist/arguments/BoolArgumentType.js +3 -5
  9. package/dist/arguments/FloatArgumentType.d.ts +2 -1
  10. package/dist/arguments/FloatArgumentType.js +5 -4
  11. package/dist/arguments/IntegerArgumentType.d.ts +2 -1
  12. package/dist/arguments/IntegerArgumentType.js +5 -4
  13. package/dist/arguments/LongArgumentType.d.ts +2 -1
  14. package/dist/arguments/LongArgumentType.js +5 -4
  15. package/dist/arguments/NumberArgumentType.d.ts +3 -1
  16. package/dist/arguments/NumberArgumentType.js +2 -2
  17. package/dist/arguments/StringArgumentType.d.ts +2 -1
  18. package/dist/arguments/StringArgumentType.js +2 -2
  19. package/dist/builder/ArgumentBuilder.d.ts +5 -2
  20. package/dist/builder/ArgumentBuilder.js +4 -3
  21. package/dist/builder/LiteralArgumentBuilder.d.ts +3 -2
  22. package/dist/builder/LiteralArgumentBuilder.js +4 -3
  23. package/dist/builder/RequiredArgumentBuilder.d.ts +4 -2
  24. package/dist/builder/RequiredArgumentBuilder.js +4 -3
  25. package/dist/context/CommandContext.d.ts +8 -3
  26. package/dist/context/CommandContextBuilder.d.ts +10 -3
  27. package/dist/context/CommandContextBuilder.js +12 -9
  28. package/dist/context/ParsedArgument.d.ts +1 -1
  29. package/dist/context/ParsedArgument.js +2 -2
  30. package/dist/context/ParsedCommandNode.d.ts +2 -1
  31. package/dist/context/SuggestionContext.d.ts +1 -1
  32. package/dist/exceptions/CommandErrorType.d.ts +3 -2
  33. package/dist/exceptions/CommandErrorType.js +3 -3
  34. package/dist/exceptions/CommandSyntaxError.d.ts +1 -1
  35. package/dist/exceptions/CommandSyntaxError.js +23 -23
  36. package/dist/index.d.ts +18 -18
  37. package/dist/index.js +18 -18
  38. package/dist/suggestion/Suggestion.d.ts +1 -1
  39. package/dist/suggestion/Suggestions.d.ts +2 -1
  40. package/dist/suggestion/Suggestions.js +3 -3
  41. package/dist/suggestion/SuggestionsBuilder.d.ts +1 -1
  42. package/dist/suggestion/SuggestionsBuilder.js +5 -3
  43. package/dist/tree/ArgumentCommandNode.d.ts +12 -1
  44. package/dist/tree/ArgumentCommandNode.js +6 -3
  45. package/dist/tree/CommandNode.d.ts +16 -1
  46. package/dist/tree/CommandNode.js +10 -3
  47. package/dist/tree/LiteralCommandNode.d.ts +11 -1
  48. package/dist/tree/LiteralCommandNode.js +10 -5
  49. package/dist/tree/RootCommandNode.d.ts +6 -1
  50. package/dist/tree/RootCommandNode.js +4 -3
  51. package/dist/tree/internal.d.ts +3 -0
  52. package/dist/tree/internal.js +7 -0
  53. package/dist/tree/internal2.d.ts +6 -0
  54. package/dist/tree/internal2.js +10 -0
  55. package/dist/tsconfig.tsbuildinfo +1 -1
  56. package/package.json +1 -1
  57. package/src/Command.ts +1 -1
  58. package/src/CommandDispatcher.ts +5 -5
  59. package/src/ParseResults.ts +1 -1
  60. package/src/arguments/ArgumentType.ts +5 -7
  61. package/src/arguments/BoolArgumentType.ts +6 -7
  62. package/src/arguments/FloatArgumentType.ts +3 -1
  63. package/src/arguments/IntegerArgumentType.ts +3 -1
  64. package/src/arguments/LongArgumentType.ts +3 -1
  65. package/src/arguments/NumberArgumentType.ts +3 -1
  66. package/src/arguments/StringArgumentType.ts +2 -1
  67. package/src/builder/ArgumentBuilder.ts +8 -8
  68. package/src/builder/LiteralArgumentBuilder.ts +3 -2
  69. package/src/builder/RequiredArgumentBuilder.ts +4 -2
  70. package/src/context/CommandContext.ts +10 -12
  71. package/src/context/CommandContextBuilder.ts +12 -14
  72. package/src/context/ParsedArgument.ts +1 -1
  73. package/src/context/ParsedCommandNode.ts +2 -1
  74. package/src/context/SuggestionContext.ts +1 -1
  75. package/src/exceptions/CommandErrorType.ts +3 -2
  76. package/src/exceptions/CommandSyntaxError.ts +1 -1
  77. package/src/index.ts +18 -18
  78. package/src/suggestion/Suggestion.ts +1 -1
  79. package/src/suggestion/Suggestions.ts +2 -1
  80. package/src/suggestion/SuggestionsBuilder.ts +3 -1
  81. package/src/tree/ArgumentCommandNode.ts +13 -13
  82. package/src/tree/CommandNode.ts +25 -17
  83. package/src/tree/LiteralCommandNode.ts +13 -13
  84. package/src/tree/RootCommandNode.ts +6 -8
  85. package/src/tree/internal.ts +9 -0
  86. package/src/tree/internal2.ts +6 -0
  87. package/test/Arguments.test.ts +3 -4
package/README.md CHANGED
@@ -4,6 +4,7 @@ Fork of [brigadier-ts](https://github.com/misode/brigadier-ts) with some changes
4
4
 
5
5
  - (breaking change) Predicates and Commands are async
6
6
  - Non-literal arguments don't unconditionally return empty suggestions (WHY DID THIS EXIST???)
7
+ - No circular dependencies
7
8
  - Update branding
8
9
 
9
10
  (not many, but we'll probably add more later)
@@ -24,7 +25,7 @@ import {
24
25
  IntegerArgumentType,
25
26
  literal,
26
27
  argument
27
- } from "brigadier-ts";
28
+ } from "@wq2/brigadier-ts";
28
29
 
29
30
  class CommandSource {
30
31
  private a: number;
@@ -62,7 +63,7 @@ import {
62
63
  IntegerArgumentType,
63
64
  literal,
64
65
  argument
65
- } from "brigadier-ts";
66
+ } from "@wq2/brigadier-ts";
66
67
 
67
68
  const dispatcher = new CommandDispatcher<number>();
68
69
  const execute = dispatcher.register(literal("execute"));
@@ -100,7 +101,7 @@ import {
100
101
  IntegerArgumentType,
101
102
  literal,
102
103
  argument
103
- } from "brigadier-ts";
104
+ } from "@wq2/brigadier-ts";
104
105
 
105
106
  const dispatcher = new CommandDispatcher<number>();
106
107
  dispatcher.register(literal("double")
package/dist/Command.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import type { CommandContext } from "./";
1
+ import type { CommandContext } from "./context/CommandContext";
2
2
  export type Command<S> = (c: CommandContext<S>) => Promise<number | void>;
@@ -1,4 +1,4 @@
1
- import { RootCommandNode, type LiteralCommandNode, StringReader, type LiteralArgumentBuilder, type CommandNode, ParseResults, Suggestions } from ".";
1
+ import { type CommandNode, type LiteralArgumentBuilder, type LiteralCommandNode, ParseResults, RootCommandNode, StringReader, Suggestions } from ".";
2
2
  export declare class CommandDispatcher<S> {
3
3
  private root;
4
4
  private static USAGE_OPTIONAL_OPEN;
@@ -1,4 +1,4 @@
1
- import type { CommandContextBuilder, StringReader, CommandNode, CommandSyntaxError } from ".";
1
+ import type { CommandContextBuilder, CommandNode, CommandSyntaxError, StringReader } from ".";
2
2
  export declare class ParseResults<S> {
3
3
  private context;
4
4
  private reader;
@@ -1,5 +1,8 @@
1
- import { type StringReader, type CommandContext, Suggestions, type SuggestionsBuilder } from "..";
1
+ import type { CommandContext } from "../context/CommandContext";
2
+ import type { StringReader } from "../StringReader";
3
+ import { Suggestions } from "../suggestion/Suggestions";
4
+ import type { SuggestionsBuilder } from "../suggestion/SuggestionsBuilder";
2
5
  export declare abstract class ArgumentType<T> {
3
6
  abstract parse(reader: StringReader): T;
4
- listSuggestions(context: CommandContext<any>, builder: SuggestionsBuilder): Promise<Suggestions>;
7
+ listSuggestions(context: CommandContext<unknown>, builder: SuggestionsBuilder): Promise<Suggestions>;
5
8
  }
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ArgumentType = void 0;
4
- const __1 = require("..");
4
+ const Suggestions_1 = require("../suggestion/Suggestions");
5
5
  class ArgumentType {
6
6
  listSuggestions(
7
7
  // biome-ignore lint/correctness/noUnusedFunctionParameters: optional override
8
8
  context,
9
9
  // biome-ignore lint/correctness/noUnusedFunctionParameters: optional override
10
10
  builder) {
11
- return __1.Suggestions.empty();
11
+ return Suggestions_1.Suggestions.empty();
12
12
  }
13
13
  }
14
14
  exports.ArgumentType = ArgumentType;
@@ -1,10 +1,10 @@
1
- import { ArgumentType } from "./ArgumentType";
2
- import type { StringReader } from "../StringReader";
3
1
  import type { CommandContext } from "../context/CommandContext";
4
- import type { SuggestionsBuilder } from "../suggestion/SuggestionsBuilder";
2
+ import type { StringReader } from "../StringReader";
5
3
  import type { Suggestions } from "../suggestion/Suggestions";
4
+ import type { SuggestionsBuilder } from "../suggestion/SuggestionsBuilder";
5
+ import { ArgumentType } from "./ArgumentType";
6
6
  export declare class BoolArgumentType extends ArgumentType<boolean> {
7
7
  parse(reader: StringReader): boolean;
8
- listSuggestions(context: CommandContext<any>, builder: SuggestionsBuilder): Promise<Suggestions>;
8
+ listSuggestions(_ctx: CommandContext<unknown>, builder: SuggestionsBuilder): Promise<Suggestions>;
9
9
  }
10
10
  export declare function bool(): BoolArgumentType;
@@ -7,14 +7,12 @@ class BoolArgumentType extends ArgumentType_1.ArgumentType {
7
7
  parse(reader) {
8
8
  return reader.readBoolean();
9
9
  }
10
- listSuggestions(
11
- // biome-ignore lint/correctness/noUnusedFunctionParameters: optional override
12
- context, builder) {
10
+ listSuggestions(_ctx, builder) {
13
11
  if ("true".startsWith(builder.getRemaining().toLowerCase())) {
14
- builder.suggest("true");
12
+ return builder.suggest("true").buildPromise();
15
13
  }
16
14
  if ("false".startsWith(builder.getRemaining().toLowerCase())) {
17
- builder.suggest("false");
15
+ return builder.suggest("false").buildPromise();
18
16
  }
19
17
  return builder.buildPromise();
20
18
  }
@@ -1,4 +1,5 @@
1
- import { type StringReader, NumberArgumentType } from "..";
1
+ import type { StringReader } from "../StringReader";
2
+ import { NumberArgumentType } from "./NumberArgumentType";
2
3
  export declare class FloatArgumentType extends NumberArgumentType {
3
4
  constructor(minimum?: number, maximum?: number);
4
5
  readNumber(reader: StringReader): number;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FloatArgumentType = void 0;
4
- const __1 = require("..");
5
- class FloatArgumentType extends __1.NumberArgumentType {
4
+ const CommandSyntaxError_1 = require("../exceptions/CommandSyntaxError");
5
+ const NumberArgumentType_1 = require("./NumberArgumentType");
6
+ class FloatArgumentType extends NumberArgumentType_1.NumberArgumentType {
6
7
  constructor(minimum = -Infinity, maximum = Infinity) {
7
8
  super(minimum, maximum);
8
9
  }
@@ -10,10 +11,10 @@ class FloatArgumentType extends __1.NumberArgumentType {
10
11
  return reader.readFloat();
11
12
  }
12
13
  getTooSmallError() {
13
- return __1.CommandSyntaxError.FLOAT_TOO_SMALL;
14
+ return CommandSyntaxError_1.CommandSyntaxError.FLOAT_TOO_SMALL;
14
15
  }
15
16
  getTooBigError() {
16
- return __1.CommandSyntaxError.FLOAT_TOO_BIG;
17
+ return CommandSyntaxError_1.CommandSyntaxError.FLOAT_TOO_BIG;
17
18
  }
18
19
  }
19
20
  exports.FloatArgumentType = FloatArgumentType;
@@ -1,4 +1,5 @@
1
- import { type StringReader, NumberArgumentType } from "..";
1
+ import type { StringReader } from "../StringReader";
2
+ import { NumberArgumentType } from "./NumberArgumentType";
2
3
  export declare class IntegerArgumentType extends NumberArgumentType {
3
4
  constructor(minimum?: number, maximum?: number);
4
5
  readNumber(reader: StringReader): number;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IntegerArgumentType = void 0;
4
- const __1 = require("..");
5
- class IntegerArgumentType extends __1.NumberArgumentType {
4
+ const CommandSyntaxError_1 = require("../exceptions/CommandSyntaxError");
5
+ const NumberArgumentType_1 = require("./NumberArgumentType");
6
+ class IntegerArgumentType extends NumberArgumentType_1.NumberArgumentType {
6
7
  constructor(minimum = -2147483648, maximum = 2147483647) {
7
8
  super(minimum, maximum);
8
9
  }
@@ -10,10 +11,10 @@ class IntegerArgumentType extends __1.NumberArgumentType {
10
11
  return reader.readInt();
11
12
  }
12
13
  getTooSmallError() {
13
- return __1.CommandSyntaxError.INTEGER_TOO_SMALL;
14
+ return CommandSyntaxError_1.CommandSyntaxError.INTEGER_TOO_SMALL;
14
15
  }
15
16
  getTooBigError() {
16
- return __1.CommandSyntaxError.INTEGER_TOO_BIG;
17
+ return CommandSyntaxError_1.CommandSyntaxError.INTEGER_TOO_BIG;
17
18
  }
18
19
  }
19
20
  exports.IntegerArgumentType = IntegerArgumentType;
@@ -1,4 +1,5 @@
1
- import { type StringReader, NumberArgumentType } from "..";
1
+ import type { StringReader } from "../StringReader";
2
+ import { NumberArgumentType } from "./NumberArgumentType";
2
3
  export declare class LongArgumentType extends NumberArgumentType<bigint> {
3
4
  private static readonly MIN;
4
5
  private static readonly MAX;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LongArgumentType = void 0;
4
- const __1 = require("..");
5
- class LongArgumentType extends __1.NumberArgumentType {
4
+ const CommandSyntaxError_1 = require("../exceptions/CommandSyntaxError");
5
+ const NumberArgumentType_1 = require("./NumberArgumentType");
6
+ class LongArgumentType extends NumberArgumentType_1.NumberArgumentType {
6
7
  constructor(minimum = LongArgumentType.MIN, maximum = LongArgumentType.MAX) {
7
8
  super(minimum, maximum);
8
9
  }
@@ -10,10 +11,10 @@ class LongArgumentType extends __1.NumberArgumentType {
10
11
  return reader.readLong();
11
12
  }
12
13
  getTooSmallError() {
13
- return __1.CommandSyntaxError.LONG_TOO_SMALL;
14
+ return CommandSyntaxError_1.CommandSyntaxError.LONG_TOO_SMALL;
14
15
  }
15
16
  getTooBigError() {
16
- return __1.CommandSyntaxError.LONG_TOO_BIG;
17
+ return CommandSyntaxError_1.CommandSyntaxError.LONG_TOO_BIG;
17
18
  }
18
19
  }
19
20
  exports.LongArgumentType = LongArgumentType;
@@ -1,4 +1,6 @@
1
- import { ArgumentType, type StringReader, type CommandErrorType } from "..";
1
+ import type { CommandErrorType } from "../exceptions/CommandErrorType";
2
+ import type { StringReader } from "../StringReader";
3
+ import { ArgumentType } from "./ArgumentType";
2
4
  export declare abstract class NumberArgumentType<N extends number | bigint = number> extends ArgumentType<N> {
3
5
  private minimum;
4
6
  private maximum;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NumberArgumentType = void 0;
4
- const __1 = require("..");
5
- class NumberArgumentType extends __1.ArgumentType {
4
+ const ArgumentType_1 = require("./ArgumentType");
5
+ class NumberArgumentType extends ArgumentType_1.ArgumentType {
6
6
  constructor(minimum, maximum) {
7
7
  super();
8
8
  this.minimum = minimum;
@@ -1,4 +1,5 @@
1
- import { ArgumentType, type StringReader } from "..";
1
+ import type { StringReader } from "../StringReader";
2
+ import { ArgumentType } from "./ArgumentType";
2
3
  type StringType = "single_word" | "quotable_phrase" | "greedy_phrase";
3
4
  export declare class StringArgumentType extends ArgumentType<string> {
4
5
  private type;
@@ -4,8 +4,8 @@ exports.StringArgumentType = void 0;
4
4
  exports.word = word;
5
5
  exports.string = string;
6
6
  exports.greedyString = greedyString;
7
- const __1 = require("..");
8
- class StringArgumentType extends __1.ArgumentType {
7
+ const ArgumentType_1 = require("./ArgumentType");
8
+ class StringArgumentType extends ArgumentType_1.ArgumentType {
9
9
  constructor(type) {
10
10
  super();
11
11
  this.type = type;
@@ -1,4 +1,7 @@
1
- import { CommandNode, type Command, type Predicate, type CommandContext } from "..";
1
+ import type { Command } from "../Command";
2
+ import type { CommandContext } from "../context/CommandContext";
3
+ import type { Predicate } from "../Predicate";
4
+ import { CommandNode } from "../tree/CommandNode";
2
5
  export type RedirectModifier<S> = (context: CommandContext<S>) => S | S[];
3
6
  export declare abstract class ArgumentBuilder<S, T extends ArgumentBuilder<S, T>> {
4
7
  private arguments;
@@ -9,7 +12,7 @@ export declare abstract class ArgumentBuilder<S, T extends ArgumentBuilder<S, T>
9
12
  private forks;
10
13
  constructor();
11
14
  abstract getThis(): T;
12
- then(argument: ArgumentBuilder<S, any> | CommandNode<S>): T;
15
+ then<A extends ArgumentBuilder<S, A>>(argument: ArgumentBuilder<S, A> | CommandNode<S>): T;
13
16
  executes(command: Command<S>): T;
14
17
  requires(requirement: Predicate<S>): T;
15
18
  redirect(target: CommandNode<S>, modifier?: RedirectModifier<S>): T;
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ArgumentBuilder = void 0;
4
- const __1 = require("..");
4
+ const CommandNode_1 = require("../tree/CommandNode");
5
+ const RootCommandNode_1 = require("../tree/RootCommandNode");
5
6
  class ArgumentBuilder {
6
7
  constructor() {
7
- this.arguments = new __1.RootCommandNode();
8
+ this.arguments = new RootCommandNode_1.RootCommandNode();
8
9
  this.requirement = async (_) => true;
9
10
  }
10
11
  // biome-ignore lint/suspicious/noThenProperty: proof?
11
12
  then(argument) {
12
- const child = argument instanceof __1.CommandNode ? argument : argument.build();
13
+ const child = argument instanceof CommandNode_1.CommandNode ? argument : argument.build();
13
14
  this.arguments.addChild(child);
14
15
  return this.getThis();
15
16
  }
@@ -1,4 +1,5 @@
1
- import { ArgumentBuilder, LiteralCommandNode } from "..";
1
+ import { LiteralCommandNode } from "../tree/LiteralCommandNode";
2
+ import { ArgumentBuilder } from "./ArgumentBuilder";
2
3
  export declare class LiteralArgumentBuilder<S> extends ArgumentBuilder<S, LiteralArgumentBuilder<S>> {
3
4
  private literal;
4
5
  constructor(literal: string);
@@ -6,4 +7,4 @@ export declare class LiteralArgumentBuilder<S> extends ArgumentBuilder<S, Litera
6
7
  getLiteral(): string;
7
8
  build(): LiteralCommandNode<S>;
8
9
  }
9
- export declare function literal<S = any>(name: string): LiteralArgumentBuilder<S>;
10
+ export declare function literal<S = unknown>(name: string): LiteralArgumentBuilder<S>;
@@ -2,8 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LiteralArgumentBuilder = void 0;
4
4
  exports.literal = literal;
5
- const __1 = require("..");
6
- class LiteralArgumentBuilder extends __1.ArgumentBuilder {
5
+ const LiteralCommandNode_1 = require("../tree/LiteralCommandNode");
6
+ const ArgumentBuilder_1 = require("./ArgumentBuilder");
7
+ class LiteralArgumentBuilder extends ArgumentBuilder_1.ArgumentBuilder {
7
8
  constructor(literal) {
8
9
  super();
9
10
  this.literal = literal;
@@ -15,7 +16,7 @@ class LiteralArgumentBuilder extends __1.ArgumentBuilder {
15
16
  return this.literal;
16
17
  }
17
18
  build() {
18
- const result = new __1.LiteralCommandNode(this.getLiteral(), this.getCommand(), this.getRequirement(), this.getRedirect(), this.getRedirectModifier(), this.isFork());
19
+ const result = new LiteralCommandNode_1.LiteralCommandNode(this.getLiteral(), this.getCommand(), this.getRequirement(), this.getRedirect(), this.getRedirectModifier(), this.isFork());
19
20
  for (const argument of this.getArguments()) {
20
21
  result.addChild(argument);
21
22
  }
@@ -1,4 +1,6 @@
1
- import { ArgumentBuilder, type ArgumentType, ArgumentCommandNode } from "..";
1
+ import type { ArgumentType } from "../arguments/ArgumentType";
2
+ import { ArgumentCommandNode } from "../tree/ArgumentCommandNode";
3
+ import { ArgumentBuilder } from "./ArgumentBuilder";
2
4
  export declare class RequiredArgumentBuilder<S, T> extends ArgumentBuilder<S, RequiredArgumentBuilder<S, T>> {
3
5
  private name;
4
6
  private type;
@@ -8,4 +10,4 @@ export declare class RequiredArgumentBuilder<S, T> extends ArgumentBuilder<S, Re
8
10
  getType(): ArgumentType<T>;
9
11
  build(): ArgumentCommandNode<S, T>;
10
12
  }
11
- export declare function argument<S = any, T = any>(name: string, type: ArgumentType<T>): RequiredArgumentBuilder<S, T>;
13
+ export declare function argument<S = unknown, T = unknown>(name: string, type: ArgumentType<T>): RequiredArgumentBuilder<S, T>;
@@ -2,8 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RequiredArgumentBuilder = void 0;
4
4
  exports.argument = argument;
5
- const __1 = require("..");
6
- class RequiredArgumentBuilder extends __1.ArgumentBuilder {
5
+ const ArgumentCommandNode_1 = require("../tree/ArgumentCommandNode");
6
+ const ArgumentBuilder_1 = require("./ArgumentBuilder");
7
+ class RequiredArgumentBuilder extends ArgumentBuilder_1.ArgumentBuilder {
7
8
  constructor(name, type) {
8
9
  super();
9
10
  this.name = name;
@@ -19,7 +20,7 @@ class RequiredArgumentBuilder extends __1.ArgumentBuilder {
19
20
  return this.type;
20
21
  }
21
22
  build() {
22
- const result = new __1.ArgumentCommandNode(this.getName(), this.getType(), this.getCommand(), this.getRequirement(), this.getRedirect(), this.getRedirectModifier(), this.isFork());
23
+ const result = new ArgumentCommandNode_1.ArgumentCommandNode(this.getName(), this.getType(), this.getCommand(), this.getRequirement(), this.getRedirect(), this.getRedirectModifier(), this.isFork());
23
24
  for (const argument of this.getArguments()) {
24
25
  result.addChild(argument);
25
26
  }
@@ -1,4 +1,9 @@
1
- import type { Command, CommandNode, StringRange, ParsedArgument, ParsedCommandNode, RedirectModifier } from "..";
1
+ import type { RedirectModifier } from "../builder/ArgumentBuilder";
2
+ import type { Command } from "../Command";
3
+ import type { CommandNode } from "../tree/CommandNode";
4
+ import type { ParsedArgument } from "./ParsedArgument";
5
+ import type { ParsedCommandNode } from "./ParsedCommandNode";
6
+ import type { StringRange } from "./StringRange";
2
7
  export declare class CommandContext<S> {
3
8
  private source;
4
9
  private input;
@@ -10,14 +15,14 @@ export declare class CommandContext<S> {
10
15
  private range;
11
16
  private modifier;
12
17
  private forks;
13
- constructor(source: S, input: string, parsedArguments: Map<string, ParsedArgument<any>>, command: Command<S>, rootNode: CommandNode<S>, nodes: ParsedCommandNode<S>[], range: StringRange, child: CommandContext<S>, modifier: RedirectModifier<S>, forks: boolean);
18
+ constructor(source: S, input: string, parsedArguments: Map<string, ParsedArgument<unknown>>, command: Command<S>, rootNode: CommandNode<S>, nodes: ParsedCommandNode<S>[], range: StringRange, child: CommandContext<S>, modifier: RedirectModifier<S>, forks: boolean);
14
19
  copyFor(source: S): CommandContext<S>;
15
20
  getChild(): CommandContext<S>;
16
21
  getLastChild(): CommandContext<S>;
17
22
  getCommand(): Command<S>;
18
23
  getSource(): S;
19
24
  getRootNode(): CommandNode<S>;
20
- get(name: string): any;
25
+ get<R = unknown>(name: string): R;
21
26
  getRedirectModifier(): RedirectModifier<S>;
22
27
  getRange(): StringRange;
23
28
  getInput(): string;
@@ -1,4 +1,11 @@
1
- import { type CommandNode, type CommandDispatcher, type Command, CommandContext, StringRange, ParsedCommandNode, type ParsedArgument, SuggestionContext } from "..";
1
+ import type { Command } from "../Command";
2
+ import type { CommandDispatcher } from "../CommandDispatcher";
3
+ import type { CommandNode } from "../tree/CommandNode";
4
+ import { CommandContext } from "./CommandContext";
5
+ import type { ParsedArgument } from "./ParsedArgument";
6
+ import { ParsedCommandNode } from "./ParsedCommandNode";
7
+ import { StringRange } from "./StringRange";
8
+ import { SuggestionContext } from "./SuggestionContext";
2
9
  export declare class CommandContextBuilder<S> {
3
10
  private source;
4
11
  private arguments;
@@ -14,8 +21,8 @@ export declare class CommandContextBuilder<S> {
14
21
  withSource(source: S): CommandContextBuilder<S>;
15
22
  getSource(): S;
16
23
  getRootNode(): CommandNode<S>;
17
- withArgument(name: string, argument: ParsedArgument<any>): CommandContextBuilder<S>;
18
- getArguments(): Map<string, ParsedArgument<any>>;
24
+ withArgument(name: string, argument: ParsedArgument<unknown>): CommandContextBuilder<S>;
25
+ getArguments(): Map<string, ParsedArgument<unknown>>;
19
26
  withChild(child: CommandContextBuilder<S>): CommandContextBuilder<S>;
20
27
  getChild(): CommandContextBuilder<S>;
21
28
  getLastChild(): CommandContextBuilder<S>;
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommandContextBuilder = void 0;
4
- const __1 = require("..");
4
+ const CommandContext_1 = require("./CommandContext");
5
+ const ParsedCommandNode_1 = require("./ParsedCommandNode");
6
+ const StringRange_1 = require("./StringRange");
7
+ const SuggestionContext_1 = require("./SuggestionContext");
5
8
  class CommandContextBuilder {
6
9
  constructor(dispatcher, source, rootNode, start) {
7
10
  this.dispatcher = dispatcher;
8
11
  this.source = source;
9
12
  this.rootNode = rootNode;
10
- this.range = __1.StringRange.at(start);
13
+ this.range = StringRange_1.StringRange.at(start);
11
14
  this.nodes = [];
12
15
  this.arguments = new Map();
13
16
  }
@@ -50,8 +53,8 @@ class CommandContextBuilder {
50
53
  return this.command;
51
54
  }
52
55
  withNode(node, range) {
53
- this.nodes.push(new __1.ParsedCommandNode(node, range));
54
- this.range = __1.StringRange.encompassing(this.range, range);
56
+ this.nodes.push(new ParsedCommandNode_1.ParsedCommandNode(node, range));
57
+ this.range = StringRange_1.StringRange.encompassing(this.range, range);
55
58
  this.modifier = node.getRedirectModifier();
56
59
  this.forks = node.isFork();
57
60
  return this;
@@ -72,7 +75,7 @@ class CommandContextBuilder {
72
75
  }
73
76
  build(input) {
74
77
  const child = this.child == null ? null : this.child.build(input);
75
- return new __1.CommandContext(this.source, input, this.arguments, this.command, this.rootNode, this.nodes, this.range, child, this.modifier, this.forks);
78
+ return new CommandContext_1.CommandContext(this.source, input, this.arguments, this.command, this.rootNode, this.nodes, this.range, child, this.modifier, this.forks);
76
79
  }
77
80
  getDispatcher() {
78
81
  return this.dispatcher;
@@ -88,10 +91,10 @@ class CommandContextBuilder {
88
91
  }
89
92
  else if (this.nodes.length > 0) {
90
93
  const last = this.nodes[this.nodes.length - 1];
91
- return new __1.SuggestionContext(last.getNode(), last.getRange().getEnd() + 1);
94
+ return new SuggestionContext_1.SuggestionContext(last.getNode(), last.getRange().getEnd() + 1);
92
95
  }
93
96
  else {
94
- return new __1.SuggestionContext(this.rootNode, this.range.getStart());
97
+ return new SuggestionContext_1.SuggestionContext(this.rootNode, this.range.getStart());
95
98
  }
96
99
  }
97
100
  else {
@@ -99,14 +102,14 @@ class CommandContextBuilder {
99
102
  for (const node of this.nodes) {
100
103
  const nodeRange = node.getRange();
101
104
  if (nodeRange.getStart() <= cursor && cursor <= nodeRange.getEnd()) {
102
- return new __1.SuggestionContext(prev, nodeRange.getStart());
105
+ return new SuggestionContext_1.SuggestionContext(prev, nodeRange.getStart());
103
106
  }
104
107
  prev = node.getNode();
105
108
  }
106
109
  if (prev === null) {
107
110
  throw new Error("Can't find node before cursor");
108
111
  }
109
- return new __1.SuggestionContext(prev, this.range.getStart());
112
+ return new SuggestionContext_1.SuggestionContext(prev, this.range.getStart());
110
113
  }
111
114
  }
112
115
  throw new Error("Can't find node before cursor");
@@ -1,4 +1,4 @@
1
- import { StringRange } from "..";
1
+ import { StringRange } from "./StringRange";
2
2
  export declare class ParsedArgument<T> {
3
3
  private range;
4
4
  private result;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ParsedArgument = void 0;
4
- const __1 = require("..");
4
+ const StringRange_1 = require("./StringRange");
5
5
  class ParsedArgument {
6
6
  constructor(start, end, result) {
7
- this.range = new __1.StringRange(start, end);
7
+ this.range = new StringRange_1.StringRange(start, end);
8
8
  this.result = result;
9
9
  }
10
10
  getRange() {
@@ -1,4 +1,5 @@
1
- import type { CommandNode, StringRange } from "..";
1
+ import type { CommandNode } from "../tree/CommandNode";
2
+ import type { StringRange } from "./StringRange";
2
3
  export declare class ParsedCommandNode<S> {
3
4
  private node;
4
5
  private range;
@@ -1,4 +1,4 @@
1
- import type { CommandNode } from "..";
1
+ import type { CommandNode } from "../tree/CommandNode";
2
2
  export declare class SuggestionContext<S> {
3
3
  parent: CommandNode<S>;
4
4
  startPos: number;
@@ -1,5 +1,6 @@
1
- import { CommandSyntaxError, type StringReader } from "..";
2
- type CommandErrorFunction = (...args: any[]) => string;
1
+ import type { StringReader } from "../StringReader";
2
+ import { CommandSyntaxError } from "./CommandSyntaxError";
3
+ type CommandErrorFunction = <A = unknown>(...args: A[]) => string;
3
4
  export declare class CommandErrorType {
4
5
  private func;
5
6
  constructor(func: CommandErrorFunction);
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommandErrorType = void 0;
4
- const __1 = require("..");
4
+ const CommandSyntaxError_1 = require("./CommandSyntaxError");
5
5
  class CommandErrorType {
6
6
  constructor(func) {
7
7
  this.func = func;
8
8
  }
9
9
  create(...args) {
10
10
  const message = this.func(...args);
11
- return new __1.CommandSyntaxError(message);
11
+ return new CommandSyntaxError_1.CommandSyntaxError(message);
12
12
  }
13
13
  createWithContext(reader, ...args) {
14
14
  const message = this.func(...args);
15
- return new __1.CommandSyntaxError(message, reader.getString(), reader.getCursor());
15
+ return new CommandSyntaxError_1.CommandSyntaxError(message, reader.getString(), reader.getCursor());
16
16
  }
17
17
  }
18
18
  exports.CommandErrorType = CommandErrorType;
@@ -1,4 +1,4 @@
1
- import { CommandErrorType } from "..";
1
+ import { CommandErrorType } from "./CommandErrorType";
2
2
  export declare class CommandSyntaxError extends Error {
3
3
  private input;
4
4
  private cursor;