@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.
Files changed (78) hide show
  1. package/dist/Command.d.ts +2 -2
  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 +3 -2
  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
package/dist/index.d.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";
package/dist/index.js CHANGED
@@ -14,33 +14,33 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Command"), exports);
18
- __exportStar(require("./Predicate"), exports);
19
- __exportStar(require("./context/StringRange"), exports);
20
- __exportStar(require("./exceptions/CommandErrorType"), exports);
21
- __exportStar(require("./exceptions/CommandSyntaxError"), exports);
22
- __exportStar(require("./StringReader"), exports);
23
- __exportStar(require("./suggestion/Suggestion"), exports);
24
- __exportStar(require("./suggestion/Suggestions"), exports);
25
- __exportStar(require("./suggestion/SuggestionsBuilder"), exports);
26
- __exportStar(require("./tree/CommandNode"), exports);
27
- __exportStar(require("./tree/LiteralCommandNode"), exports);
28
- __exportStar(require("./tree/ArgumentCommandNode"), exports);
29
- __exportStar(require("./tree/RootCommandNode"), exports);
30
17
  __exportStar(require("./arguments/ArgumentType"), exports);
31
- __exportStar(require("./arguments/NumberArgumentType"), exports);
18
+ __exportStar(require("./arguments/BoolArgumentType"), exports);
32
19
  __exportStar(require("./arguments/FloatArgumentType"), exports);
33
20
  __exportStar(require("./arguments/IntegerArgumentType"), exports);
34
21
  __exportStar(require("./arguments/LongArgumentType"), exports);
35
- __exportStar(require("./arguments/BoolArgumentType"), exports);
22
+ __exportStar(require("./arguments/NumberArgumentType"), exports);
36
23
  __exportStar(require("./arguments/StringArgumentType"), exports);
37
24
  __exportStar(require("./builder/ArgumentBuilder"), exports);
38
25
  __exportStar(require("./builder/LiteralArgumentBuilder"), exports);
39
26
  __exportStar(require("./builder/RequiredArgumentBuilder"), exports);
40
- __exportStar(require("./context/ParsedArgument"), exports);
41
- __exportStar(require("./context/ParsedCommandNode"), exports);
27
+ __exportStar(require("./Command"), exports);
28
+ __exportStar(require("./CommandDispatcher"), exports);
42
29
  __exportStar(require("./context/CommandContext"), exports);
43
30
  __exportStar(require("./context/CommandContextBuilder"), exports);
31
+ __exportStar(require("./context/ParsedArgument"), exports);
32
+ __exportStar(require("./context/ParsedCommandNode"), exports);
33
+ __exportStar(require("./context/StringRange"), exports);
44
34
  __exportStar(require("./context/SuggestionContext"), exports);
35
+ __exportStar(require("./exceptions/CommandErrorType"), exports);
36
+ __exportStar(require("./exceptions/CommandSyntaxError"), exports);
45
37
  __exportStar(require("./ParseResults"), exports);
46
- __exportStar(require("./CommandDispatcher"), exports);
38
+ __exportStar(require("./Predicate"), exports);
39
+ __exportStar(require("./StringReader"), exports);
40
+ __exportStar(require("./suggestion/Suggestion"), exports);
41
+ __exportStar(require("./suggestion/Suggestions"), exports);
42
+ __exportStar(require("./suggestion/SuggestionsBuilder"), exports);
43
+ __exportStar(require("./tree/ArgumentCommandNode"), exports);
44
+ __exportStar(require("./tree/CommandNode"), exports);
45
+ __exportStar(require("./tree/LiteralCommandNode"), exports);
46
+ __exportStar(require("./tree/RootCommandNode"), exports);
@@ -1,4 +1,4 @@
1
- import type { StringRange } from "..";
1
+ import type { StringRange } from "../context/StringRange";
2
2
  export declare class Suggestion {
3
3
  private range;
4
4
  private text;
@@ -1,4 +1,5 @@
1
- import { StringRange, type Suggestion } from "..";
1
+ import { StringRange } from "../context/StringRange";
2
+ import type { Suggestion } from "./Suggestion";
2
3
  export declare class Suggestions {
3
4
  static EMPTY: Suggestions;
4
5
  private range;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Suggestions = void 0;
4
- const __1 = require("..");
4
+ const StringRange_1 = require("../context/StringRange");
5
5
  class Suggestions {
6
6
  constructor(range, suggestions) {
7
7
  this.range = range;
@@ -44,7 +44,7 @@ class Suggestions {
44
44
  start = Math.min(suggestion.getRange().getStart(), start);
45
45
  end = Math.max(suggestion.getRange().getEnd(), end);
46
46
  }
47
- const range = new __1.StringRange(start, end);
47
+ const range = new StringRange_1.StringRange(start, end);
48
48
  const texts = [];
49
49
  for (const suggestion of suggestions) {
50
50
  texts.push(suggestion.expand(command, range));
@@ -53,4 +53,4 @@ class Suggestions {
53
53
  }
54
54
  }
55
55
  exports.Suggestions = Suggestions;
56
- Suggestions.EMPTY = new Suggestions(__1.StringRange.at(0), []);
56
+ Suggestions.EMPTY = new Suggestions(StringRange_1.StringRange.at(0), []);
@@ -1,4 +1,4 @@
1
- import { Suggestions } from "..";
1
+ import { Suggestions } from "./Suggestions";
2
2
  export declare class SuggestionsBuilder {
3
3
  private input;
4
4
  private start;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SuggestionsBuilder = void 0;
4
- const __1 = require("..");
4
+ const StringRange_1 = require("../context/StringRange");
5
+ const Suggestion_1 = require("./Suggestion");
6
+ const Suggestions_1 = require("./Suggestions");
5
7
  class SuggestionsBuilder {
6
8
  constructor(input, start) {
7
9
  this.input = input;
@@ -19,7 +21,7 @@ class SuggestionsBuilder {
19
21
  return this.remaining;
20
22
  }
21
23
  build() {
22
- return __1.Suggestions.create(this.input, this.result);
24
+ return Suggestions_1.Suggestions.create(this.input, this.result);
23
25
  }
24
26
  buildPromise() {
25
27
  return Promise.resolve(this.build());
@@ -28,7 +30,7 @@ class SuggestionsBuilder {
28
30
  if (text === this.remaining) {
29
31
  return this;
30
32
  }
31
- this.result.push(new __1.Suggestion(new __1.StringRange(this.start, this.input.length), text, tooltip));
33
+ this.result.push(new Suggestion_1.Suggestion(new StringRange_1.StringRange(this.start, this.input.length), text, tooltip));
32
34
  return this;
33
35
  }
34
36
  add(other) {
@@ -1,4 +1,13 @@
1
- import { type ArgumentType, CommandNode, type StringReader, type Command, type CommandContext, type CommandContextBuilder, type Predicate, type RedirectModifier, type Suggestions, type SuggestionsBuilder } 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 type { Predicate } from "../Predicate";
7
+ import type { StringReader } from "../StringReader";
8
+ import type { Suggestions } from "../suggestion/Suggestions";
9
+ import type { SuggestionsBuilder } from "../suggestion/SuggestionsBuilder";
10
+ import { CommandNode } from "./CommandNode";
2
11
  export declare class ArgumentCommandNode<S, T> extends CommandNode<S> {
3
12
  name: string;
4
13
  type: ArgumentType<T>;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ArgumentCommandNode = void 0;
4
- const __1 = require("..");
5
- class ArgumentCommandNode extends __1.CommandNode {
4
+ const ParsedArgument_1 = require("../context/ParsedArgument");
5
+ const CommandNode_1 = require("./CommandNode");
6
+ class ArgumentCommandNode extends CommandNode_1.CommandNode {
6
7
  constructor(name, type, command, requirement, redirect, modifier, forks) {
7
8
  super(command, requirement, redirect, modifier, forks);
8
9
  this.name = name;
@@ -14,7 +15,7 @@ class ArgumentCommandNode extends __1.CommandNode {
14
15
  parse(reader, contextBuilder) {
15
16
  const start = reader.getCursor();
16
17
  const result = this.type.parse(reader);
17
- const parsed = new __1.ParsedArgument(start, reader.getCursor(), result);
18
+ const parsed = new ParsedArgument_1.ParsedArgument(start, reader.getCursor(), result);
18
19
  contextBuilder.withArgument(this.name, parsed);
19
20
  contextBuilder.withNode(this, parsed.getRange());
20
21
  }
@@ -1,4 +1,11 @@
1
- import { type StringReader, type Command, type CommandContext, type CommandContextBuilder, type Predicate, type RedirectModifier, type SuggestionsBuilder, type Suggestions } 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 type { Predicate } from "../Predicate";
6
+ import type { StringReader } from "../StringReader";
7
+ import type { Suggestions } from "../suggestion/Suggestions";
8
+ import type { SuggestionsBuilder } from "../suggestion/SuggestionsBuilder";
2
9
  export declare abstract class CommandNode<S> {
3
10
  private children;
4
11
  private literals;
@@ -1,4 +1,12 @@
1
- import { CommandNode, type StringReader, type Command, type CommandContext, type CommandContextBuilder, type Predicate, type RedirectModifier, Suggestions, type SuggestionsBuilder } 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 type { Predicate } from "../Predicate";
6
+ import type { StringReader } from "../StringReader";
7
+ import { Suggestions } from "../suggestion/Suggestions";
8
+ import type { SuggestionsBuilder } from "../suggestion/SuggestionsBuilder";
9
+ import { CommandNode } from "./CommandNode";
2
10
  export declare class LiteralCommandNode<S> extends CommandNode<S> {
3
11
  private literal;
4
12
  constructor(literal: string, command: Command<S>, requirement: Predicate<S>, redirect: CommandNode<S>, modifier: RedirectModifier<S>, forks: boolean);
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LiteralCommandNode = void 0;
4
- const __1 = require("..");
5
- class LiteralCommandNode extends __1.CommandNode {
4
+ const StringRange_1 = require("../context/StringRange");
5
+ const CommandSyntaxError_1 = require("../exceptions/CommandSyntaxError");
6
+ const Suggestions_1 = require("../suggestion/Suggestions");
7
+ const CommandNode_1 = require("./CommandNode");
8
+ class LiteralCommandNode extends CommandNode_1.CommandNode {
6
9
  constructor(literal, command, requirement, redirect, modifier, forks) {
7
10
  super(command, requirement, redirect, modifier, forks);
8
11
  this.literal = literal;
@@ -11,10 +14,10 @@ class LiteralCommandNode extends __1.CommandNode {
11
14
  const start = reader.getCursor();
12
15
  const end = this.parseInternal(reader);
13
16
  if (end > -1) {
14
- contextBuilder.withNode(this, new __1.StringRange(start, end));
17
+ contextBuilder.withNode(this, new StringRange_1.StringRange(start, end));
15
18
  return;
16
19
  }
17
- throw __1.CommandSyntaxError.LITERAL_INCORRECT.createWithContext(reader, this.literal);
20
+ throw CommandSyntaxError_1.CommandSyntaxError.LITERAL_INCORRECT.createWithContext(reader, this.literal);
18
21
  }
19
22
  parseInternal(reader) {
20
23
  const start = reader.getCursor();
@@ -48,7 +51,7 @@ class LiteralCommandNode extends __1.CommandNode {
48
51
  return builder.suggest(this.literal).buildPromise();
49
52
  }
50
53
  else {
51
- return __1.Suggestions.empty();
54
+ return Suggestions_1.Suggestions.empty();
52
55
  }
53
56
  }
54
57
  }
@@ -1,4 +1,9 @@
1
- import { CommandNode, type StringReader, type CommandContextBuilder, type CommandContext, Suggestions, type SuggestionsBuilder } 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";
2
7
  export declare class RootCommandNode<S> extends CommandNode<S> {
3
8
  constructor();
4
9
  parse(reader: StringReader, contextBuilder: CommandContextBuilder<S>): void;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RootCommandNode = void 0;
4
- const __1 = require("..");
5
- class RootCommandNode extends __1.CommandNode {
4
+ const Suggestions_1 = require("../suggestion/Suggestions");
5
+ const CommandNode_1 = require("./CommandNode");
6
+ class RootCommandNode extends CommandNode_1.CommandNode {
6
7
  constructor() {
7
8
  super(null, async (_) => true, null, (_) => null, false);
8
9
  }
@@ -19,7 +20,7 @@ class RootCommandNode extends __1.CommandNode {
19
20
  context,
20
21
  // biome-ignore lint/correctness/noUnusedFunctionParameters: no-op
21
22
  builder) {
22
- return __1.Suggestions.empty();
23
+ return Suggestions_1.Suggestions.empty();
23
24
  }
24
25
  }
25
26
  exports.RootCommandNode = RootCommandNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wq2/brigadier-ts",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Fork of brigadier-ts with some extra changes",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/Command.ts CHANGED
@@ -1,3 +1,4 @@
1
- import type { CommandContext } from "./";
1
+ import type { CommandContext } from "./context/CommandContext";
2
2
 
3
- export type Command<S> = (c: CommandContext<S>) => Promise<number | undefined>;
3
+ // biome-ignore lint/suspicious/noConfusingVoidType: `return undefined` :sob:
4
+ export type Command<S> = (c: CommandContext<S>) => Promise<number | void>;
@@ -1,12 +1,12 @@
1
1
  import {
2
- RootCommandNode,
3
- type LiteralCommandNode,
4
- StringReader,
5
- type LiteralArgumentBuilder,
6
2
  CommandContextBuilder,
7
3
  type CommandNode,
8
- ParseResults,
9
4
  CommandSyntaxError,
5
+ type LiteralArgumentBuilder,
6
+ type LiteralCommandNode,
7
+ ParseResults,
8
+ RootCommandNode,
9
+ StringReader,
10
10
  Suggestions,
11
11
  SuggestionsBuilder,
12
12
  } from ".";
@@ -1,8 +1,8 @@
1
1
  import type {
2
2
  CommandContextBuilder,
3
- StringReader,
4
3
  CommandNode,
5
4
  CommandSyntaxError,
5
+ StringReader,
6
6
  } from ".";
7
7
 
8
8
  export class ParseResults<S> {
@@ -1,16 +1,14 @@
1
- import {
2
- type StringReader,
3
- type CommandContext,
4
- Suggestions,
5
- type SuggestionsBuilder,
6
- } 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";
7
5
 
8
6
  export abstract class ArgumentType<T> {
9
7
  abstract parse(reader: StringReader): T;
10
8
 
11
9
  listSuggestions(
12
10
  // biome-ignore lint/correctness/noUnusedFunctionParameters: optional override
13
- context: CommandContext<any>,
11
+ context: CommandContext<unknown>,
14
12
  // biome-ignore lint/correctness/noUnusedFunctionParameters: optional override
15
13
  builder: SuggestionsBuilder,
16
14
  ): Promise<Suggestions> {
@@ -1,8 +1,8 @@
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
 
7
7
  export class BoolArgumentType extends ArgumentType<boolean> {
8
8
  parse(reader: StringReader): boolean {
@@ -10,15 +10,14 @@ export class BoolArgumentType extends ArgumentType<boolean> {
10
10
  }
11
11
 
12
12
  listSuggestions(
13
- // biome-ignore lint/correctness/noUnusedFunctionParameters: optional override
14
- context: CommandContext<any>,
13
+ _ctx: CommandContext<unknown>,
15
14
  builder: SuggestionsBuilder,
16
15
  ): Promise<Suggestions> {
17
16
  if ("true".startsWith(builder.getRemaining().toLowerCase())) {
18
- builder.suggest("true");
17
+ return builder.suggest("true").buildPromise();
19
18
  }
20
19
  if ("false".startsWith(builder.getRemaining().toLowerCase())) {
21
- builder.suggest("false");
20
+ return builder.suggest("false").buildPromise();
22
21
  }
23
22
  return builder.buildPromise();
24
23
  }
@@ -1,4 +1,6 @@
1
- import { type StringReader, NumberArgumentType, CommandSyntaxError } from "..";
1
+ import { CommandSyntaxError } from "../exceptions/CommandSyntaxError";
2
+ import type { StringReader } from "../StringReader";
3
+ import { NumberArgumentType } from "./NumberArgumentType";
2
4
 
3
5
  export class FloatArgumentType extends NumberArgumentType {
4
6
  constructor(minimum = -Infinity, maximum = Infinity) {
@@ -1,4 +1,6 @@
1
- import { type StringReader, NumberArgumentType, CommandSyntaxError } from "..";
1
+ import { CommandSyntaxError } from "../exceptions/CommandSyntaxError";
2
+ import type { StringReader } from "../StringReader";
3
+ import { NumberArgumentType } from "./NumberArgumentType";
2
4
 
3
5
  export class IntegerArgumentType extends NumberArgumentType {
4
6
  constructor(minimum = -2147483648, maximum = 2147483647) {
@@ -1,4 +1,6 @@
1
- import { type StringReader, NumberArgumentType, CommandSyntaxError } from "..";
1
+ import { CommandSyntaxError } from "../exceptions/CommandSyntaxError";
2
+ import type { StringReader } from "../StringReader";
3
+ import { NumberArgumentType } from "./NumberArgumentType";
2
4
 
3
5
  export class LongArgumentType extends NumberArgumentType<bigint> {
4
6
  private static readonly MIN = -9223372036854775808n;
@@ -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
 
3
5
  export abstract class NumberArgumentType<
4
6
  N extends number | bigint = number,
@@ -1,4 +1,5 @@
1
- import { ArgumentType, type StringReader } from "..";
1
+ import type { StringReader } from "../StringReader";
2
+ import { ArgumentType } from "./ArgumentType";
2
3
 
3
4
  type StringType = "single_word" | "quotable_phrase" | "greedy_phrase";
4
5
 
@@ -1,10 +1,8 @@
1
- import {
2
- CommandNode,
3
- RootCommandNode,
4
- type Command,
5
- type Predicate,
6
- type CommandContext,
7
- } 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";
5
+ import { RootCommandNode } from "../tree/RootCommandNode";
8
6
 
9
7
  export type RedirectModifier<S> = (context: CommandContext<S>) => S | S[];
10
8
 
@@ -24,7 +22,7 @@ export abstract class ArgumentBuilder<S, T extends ArgumentBuilder<S, T>> {
24
22
  abstract getThis(): T;
25
23
 
26
24
  // biome-ignore lint/suspicious/noThenProperty: proof?
27
- then(argument: ArgumentBuilder<S, any> | CommandNode<S>): T {
25
+ then<A extends ArgumentBuilder<S, A>>(argument: ArgumentBuilder<S, A> | CommandNode<S>): T {
28
26
  const child = argument instanceof CommandNode ? argument : argument.build();
29
27
  this.arguments.addChild(child);
30
28
  return this.getThis();
@@ -1,4 +1,5 @@
1
- import { ArgumentBuilder, LiteralCommandNode } from "..";
1
+ import { LiteralCommandNode } from "../tree/LiteralCommandNode";
2
+ import { ArgumentBuilder } from "./ArgumentBuilder";
2
3
 
3
4
  export class LiteralArgumentBuilder<S> extends ArgumentBuilder<
4
5
  S,
@@ -35,6 +36,6 @@ export class LiteralArgumentBuilder<S> extends ArgumentBuilder<
35
36
  }
36
37
  }
37
38
 
38
- export function literal<S = any>(name: string): LiteralArgumentBuilder<S> {
39
+ export function literal<S = unknown>(name: string): LiteralArgumentBuilder<S> {
39
40
  return new LiteralArgumentBuilder(name);
40
41
  }
@@ -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
 
3
5
  export class RequiredArgumentBuilder<S, T> extends ArgumentBuilder<
4
6
  S,
@@ -42,7 +44,7 @@ export class RequiredArgumentBuilder<S, T> extends ArgumentBuilder<
42
44
  }
43
45
  }
44
46
 
45
- export function argument<S = any, T = any>(
47
+ export function argument<S = unknown, T = unknown>(
46
48
  name: string,
47
49
  type: ArgumentType<T>,
48
50
  ): RequiredArgumentBuilder<S, T> {
@@ -1,16 +1,14 @@
1
- import type {
2
- Command,
3
- CommandNode,
4
- StringRange,
5
- ParsedArgument,
6
- ParsedCommandNode,
7
- RedirectModifier,
8
- } 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";
9
7
 
10
8
  export class CommandContext<S> {
11
9
  private source: S;
12
10
  private input: string;
13
- private arguments: Map<string, ParsedArgument<any>>;
11
+ private arguments: Map<string, ParsedArgument<unknown>>;
14
12
  private nodes: ParsedCommandNode<S>[];
15
13
  private command: Command<S>;
16
14
  private rootNode: CommandNode<S>;
@@ -22,7 +20,7 @@ export class CommandContext<S> {
22
20
  constructor(
23
21
  source: S,
24
22
  input: string,
25
- parsedArguments: Map<string, ParsedArgument<any>>,
23
+ parsedArguments: Map<string, ParsedArgument<unknown>>,
26
24
  command: Command<S>,
27
25
  rootNode: CommandNode<S>,
28
26
  nodes: ParsedCommandNode<S>[],
@@ -85,10 +83,10 @@ export class CommandContext<S> {
85
83
  return this.rootNode;
86
84
  }
87
85
 
88
- get(name: string): any {
86
+ get<R = unknown>(name: string): R {
89
87
  const argument = this.arguments.get(name);
90
88
  // TODO: Throw exception when argument is null
91
- return argument.getResult();
89
+ return argument.getResult() as R;
92
90
  }
93
91
 
94
92
  getRedirectModifier(): RedirectModifier<S> {
@@ -1,18 +1,16 @@
1
- import {
2
- type CommandNode,
3
- type CommandDispatcher,
4
- type Command,
5
- CommandContext,
6
- StringRange,
7
- ParsedCommandNode,
8
- type ParsedArgument,
9
- type RedirectModifier,
10
- SuggestionContext,
11
- } from "..";
1
+ import type { RedirectModifier } from "../builder/ArgumentBuilder";
2
+ import type { Command } from "../Command";
3
+ import type { CommandDispatcher } from "../CommandDispatcher";
4
+ import type { CommandNode } from "../tree/CommandNode";
5
+ import { CommandContext } from "./CommandContext";
6
+ import type { ParsedArgument } from "./ParsedArgument";
7
+ import { ParsedCommandNode } from "./ParsedCommandNode";
8
+ import { StringRange } from "./StringRange";
9
+ import { SuggestionContext } from "./SuggestionContext";
12
10
 
13
11
  export class CommandContextBuilder<S> {
14
12
  private source: S;
15
- private arguments: Map<string, ParsedArgument<any>>;
13
+ private arguments: Map<string, ParsedArgument<unknown>>;
16
14
  private rootNode: CommandNode<S>;
17
15
  private dispatcher: CommandDispatcher<S>;
18
16
  private command: Command<S>;
@@ -51,13 +49,13 @@ export class CommandContextBuilder<S> {
51
49
 
52
50
  withArgument(
53
51
  name: string,
54
- argument: ParsedArgument<any>,
52
+ argument: ParsedArgument<unknown>,
55
53
  ): CommandContextBuilder<S> {
56
54
  this.arguments.set(name, argument);
57
55
  return this;
58
56
  }
59
57
 
60
- getArguments(): Map<string, ParsedArgument<any>> {
58
+ getArguments(): Map<string, ParsedArgument<unknown>> {
61
59
  return this.arguments;
62
60
  }
63
61
 
@@ -1,4 +1,4 @@
1
- import { StringRange } from "..";
1
+ import { StringRange } from "./StringRange";
2
2
 
3
3
  export class ParsedArgument<T> {
4
4
  private range: StringRange;
@@ -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
 
3
4
  export class ParsedCommandNode<S> {
4
5
  private node: CommandNode<S>;
@@ -1,4 +1,4 @@
1
- import type { CommandNode } from "..";
1
+ import type { CommandNode } from "../tree/CommandNode";
2
2
 
3
3
  export class SuggestionContext<S> {
4
4
  parent: CommandNode<S>;