@wq2/brigadier-ts 1.0.2 → 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.
Files changed (78) hide show
  1. package/dist/Command.d.ts +1 -1
  2. package/dist/CommandDispatcher.d.ts +1 -1
  3. package/dist/ParseResults.d.ts +1 -1
  4. package/dist/arguments/ArgumentType.d.ts +5 -2
  5. package/dist/arguments/ArgumentType.js +2 -2
  6. package/dist/arguments/BoolArgumentType.d.ts +4 -4
  7. package/dist/arguments/BoolArgumentType.js +3 -5
  8. package/dist/arguments/FloatArgumentType.d.ts +2 -1
  9. package/dist/arguments/FloatArgumentType.js +5 -4
  10. package/dist/arguments/IntegerArgumentType.d.ts +2 -1
  11. package/dist/arguments/IntegerArgumentType.js +5 -4
  12. package/dist/arguments/LongArgumentType.d.ts +2 -1
  13. package/dist/arguments/LongArgumentType.js +5 -4
  14. package/dist/arguments/NumberArgumentType.d.ts +3 -1
  15. package/dist/arguments/NumberArgumentType.js +2 -2
  16. package/dist/arguments/StringArgumentType.d.ts +2 -1
  17. package/dist/arguments/StringArgumentType.js +2 -2
  18. package/dist/builder/ArgumentBuilder.d.ts +5 -2
  19. package/dist/builder/ArgumentBuilder.js +4 -3
  20. package/dist/builder/LiteralArgumentBuilder.d.ts +3 -2
  21. package/dist/builder/LiteralArgumentBuilder.js +4 -3
  22. package/dist/builder/RequiredArgumentBuilder.d.ts +4 -2
  23. package/dist/builder/RequiredArgumentBuilder.js +4 -3
  24. package/dist/context/CommandContext.d.ts +8 -3
  25. package/dist/context/CommandContextBuilder.d.ts +10 -3
  26. package/dist/context/CommandContextBuilder.js +12 -9
  27. package/dist/context/ParsedArgument.d.ts +1 -1
  28. package/dist/context/ParsedArgument.js +2 -2
  29. package/dist/context/ParsedCommandNode.d.ts +2 -1
  30. package/dist/context/SuggestionContext.d.ts +1 -1
  31. package/dist/exceptions/CommandErrorType.d.ts +3 -2
  32. package/dist/exceptions/CommandErrorType.js +3 -3
  33. package/dist/exceptions/CommandSyntaxError.d.ts +1 -1
  34. package/dist/exceptions/CommandSyntaxError.js +23 -23
  35. package/dist/index.d.ts +18 -18
  36. package/dist/index.js +18 -18
  37. package/dist/suggestion/Suggestion.d.ts +1 -1
  38. package/dist/suggestion/Suggestions.d.ts +2 -1
  39. package/dist/suggestion/Suggestions.js +3 -3
  40. package/dist/suggestion/SuggestionsBuilder.d.ts +1 -1
  41. package/dist/suggestion/SuggestionsBuilder.js +5 -3
  42. package/dist/tree/ArgumentCommandNode.d.ts +10 -1
  43. package/dist/tree/ArgumentCommandNode.js +4 -3
  44. package/dist/tree/CommandNode.d.ts +8 -1
  45. package/dist/tree/LiteralCommandNode.d.ts +9 -1
  46. package/dist/tree/LiteralCommandNode.js +8 -5
  47. package/dist/tree/RootCommandNode.d.ts +6 -1
  48. package/dist/tree/RootCommandNode.js +4 -3
  49. package/package.json +1 -1
  50. package/src/Command.ts +1 -1
  51. package/src/CommandDispatcher.ts +5 -5
  52. package/src/ParseResults.ts +1 -1
  53. package/src/arguments/ArgumentType.ts +5 -7
  54. package/src/arguments/BoolArgumentType.ts +6 -7
  55. package/src/arguments/FloatArgumentType.ts +3 -1
  56. package/src/arguments/IntegerArgumentType.ts +3 -1
  57. package/src/arguments/LongArgumentType.ts +3 -1
  58. package/src/arguments/NumberArgumentType.ts +3 -1
  59. package/src/arguments/StringArgumentType.ts +2 -1
  60. package/src/builder/ArgumentBuilder.ts +6 -8
  61. package/src/builder/LiteralArgumentBuilder.ts +3 -2
  62. package/src/builder/RequiredArgumentBuilder.ts +4 -2
  63. package/src/context/CommandContext.ts +10 -12
  64. package/src/context/CommandContextBuilder.ts +12 -14
  65. package/src/context/ParsedArgument.ts +1 -1
  66. package/src/context/ParsedCommandNode.ts +2 -1
  67. package/src/context/SuggestionContext.ts +1 -1
  68. package/src/exceptions/CommandErrorType.ts +3 -2
  69. package/src/exceptions/CommandSyntaxError.ts +1 -1
  70. package/src/index.ts +18 -18
  71. package/src/suggestion/Suggestion.ts +1 -1
  72. package/src/suggestion/Suggestions.ts +2 -1
  73. package/src/suggestion/SuggestionsBuilder.ts +3 -1
  74. package/src/tree/ArgumentCommandNode.ts +11 -13
  75. package/src/tree/CommandNode.ts +10 -13
  76. package/src/tree/LiteralCommandNode.ts +11 -13
  77. package/src/tree/RootCommandNode.ts +6 -8
  78. package/test/Arguments.test.ts +3 -4
@@ -1,6 +1,7 @@
1
- import { CommandSyntaxError, type StringReader } from "..";
1
+ import type { StringReader } from "../StringReader";
2
+ import { CommandSyntaxError } from "./CommandSyntaxError";
2
3
 
3
- type CommandErrorFunction = (...args: any[]) => string;
4
+ type CommandErrorFunction = <A = unknown>(...args: A[]) => string;
4
5
 
5
6
  export class CommandErrorType {
6
7
  private func: CommandErrorFunction;
@@ -1,4 +1,4 @@
1
- import { CommandErrorType } from "..";
1
+ import { CommandErrorType } from "./CommandErrorType";
2
2
 
3
3
  const CONTEXT_AMOUNT = 10;
4
4
 
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/NumberArgumentType";
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/BoolArgumentType";
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 "./context/ParsedArgument";
25
- export * from "./context/ParsedCommandNode";
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 "./CommandDispatcher";
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,4 @@
1
- import type { StringRange } from "..";
1
+ import type { StringRange } from "../context/StringRange";
2
2
 
3
3
  export class Suggestion {
4
4
  private range: StringRange;
@@ -1,4 +1,5 @@
1
- import { StringRange, type Suggestion } from "..";
1
+ import { StringRange } from "../context/StringRange";
2
+ import type { Suggestion } from "./Suggestion";
2
3
 
3
4
  export class Suggestions {
4
5
  static EMPTY = new Suggestions(StringRange.at(0), []);
@@ -1,4 +1,6 @@
1
- import { Suggestion, Suggestions, StringRange } from "..";
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
- type ArgumentType,
3
- CommandNode,
4
- type StringReader,
5
- type Command,
6
- type CommandContext,
7
- type CommandContextBuilder,
8
- type Predicate,
9
- type RedirectModifier,
10
- ParsedArgument,
11
- type Suggestions,
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;
@@ -1,20 +1,17 @@
1
- import {
2
- type StringReader,
3
- type Command,
4
- LiteralCommandNode,
5
- ArgumentCommandNode,
6
- type CommandContext,
7
- type CommandContextBuilder,
8
- type Predicate,
9
- type RedirectModifier,
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, any>>;
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
- CommandNode,
3
- type StringReader,
4
- type Command,
5
- StringRange,
6
- type CommandContext,
7
- type CommandContextBuilder,
8
- type Predicate,
9
- type RedirectModifier,
10
- CommandSyntaxError,
11
- Suggestions,
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
- CommandNode,
3
- type StringReader,
4
- type CommandContextBuilder,
5
- type CommandContext,
6
- Suggestions,
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() {
@@ -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
  );