From 1b71d48234cc7820e5c0b03c2512245802df5681 Mon Sep 17 00:00:00 2001 From: Jeroen Claassens Date: Wed, 10 Nov 2021 23:05:13 +0100 Subject: [PATCH] feat: deprecate ExtendedArgument closes #320 --- src/lib/structures/ExtendedArgument.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/lib/structures/ExtendedArgument.ts b/src/lib/structures/ExtendedArgument.ts index 8135a9138..3c1a9e31c 100644 --- a/src/lib/structures/ExtendedArgument.ts +++ b/src/lib/structures/ExtendedArgument.ts @@ -4,6 +4,9 @@ import { isOk } from '../parsers/Result'; import { Argument, ArgumentContext, ArgumentOptions, ArgumentResult, AsyncArgumentResult, IArgument } from './Argument'; /** + * @deprecated {@link ExtendedArgument} is deprecated and will be removed in v3.0.0. + * Use {@link Argument} instead, and abstract the resolving of the argument data to an external resolver. + * --- * The extended argument class. This class is abstract and is to be extended by subclasses which * will implement the {@link ExtendedArgument#handle} method. * Much like the {@link Argument} class, this class handles parsing user-specified command arguments @@ -52,6 +55,9 @@ import { Argument, ArgumentContext, ArgumentOptions, ArgumentResult, AsyncArgume export abstract class ExtendedArgument extends Argument { public baseArgument: K; + /** + * @deprecated {@link ExtendedArgument} is deprecated and will be removed in v3.0.0. + */ public constructor(context: PieceContext, options: ExtendedArgumentOptions) { super(context, options); this.baseArgument = options.baseArgument; @@ -60,11 +66,15 @@ export abstract class ExtendedArgument extends Argum /** * Represents the underlying argument that transforms the raw argument * into the value used to compute the extended argument's value. + * @deprecated {@link ExtendedArgument} is deprecated and will be removed in v3.0.0. */ public get base(): IArgument { return this.container.stores.get('arguments').get(this.baseArgument) as IArgument; } + /** + * @deprecated {@link ExtendedArgument} is deprecated and will be removed in v3.0.0. + */ public async run(parameter: string, context: ArgumentContext): AsyncArgumentResult { const result = await this.base.run(parameter, context as unknown as ArgumentContext); // If the result was successful (i.e. is of type `Ok`), pass its @@ -73,9 +83,15 @@ export abstract class ExtendedArgument extends Argum return isOk(result) ? this.handle(result.value, { ...context, parameter }) : result; } + /** + * @deprecated {@link ExtendedArgument} is deprecated and will be removed in v3.0.0. + */ public abstract handle(parsed: ArgType[K], context: ExtendedArgumentContext): ArgumentResult; } +/** + * @deprecated {@link ExtendedArgument} is deprecated and will be removed in v3.0.0. + */ export interface ExtendedArgumentOptions extends ArgumentOptions { /** * The name of the underlying argument whose value is used to compute @@ -84,6 +100,9 @@ export interface ExtendedArgumentOptions extends Argume baseArgument: K; } +/** + * @deprecated {@link ExtendedArgument} is deprecated and will be removed in v3.0.0. + */ export interface ExtendedArgumentContext extends ArgumentContext { /** * The canonical parameter specified by the user in the command, as