/** * @file Parseable * @module kronk/lib/Parseable */ import Helpable from '#lib/helpable.abstract'; import type { DefaultInfo, List, ParseableInfo, ParseableMetadata, ParseArg } from '@flex-development/kronk'; /** * A parse candidate. * * Parse candidates are the parseable components * of commands (e.g. arguments and options). * * @class * @abstract * @extends {Helpable} */ declare abstract class Parseable extends Helpable { /** * Candidate metadata. * * @see {@linkcode ParseableMetadata} * * @protected * @instance * @override * @member {ParseableMetadata} info */ protected info: ParseableMetadata; /** * Create a new parse candidate. * * @param {ParseableInfo | null | undefined} [info] * Parse candidate info */ constructor(info?: ParseableInfo | null | undefined); /** * The unique id for the candidate. * * @public * @abstract * @instance * * @return {string} * Unique candidate id */ abstract get id(): string; /** * Whether the candidate is required. * * Required arguments must have a value after parsing. * Required options must have a value supplied when the option is specified. * * @public * @instance * * @return {string} * `true` if required syntax was used, `false` otherwise */ get required(): boolean; /** * Whether the candidate can be specified multiple times. * * @public * @instance * * @return {string} * `true` if candidate can be specified multiple times, `false` otherwise */ get variadic(): boolean; /** * Set candidate choices. * * @see {@linkcode List} * * @public * @instance * * @param {List | null | undefined} choices * The list of allowed candidate choices * @return {this} * `this` candidate */ choices(choices: List | null | undefined): this; /** * Get candidate choices. * * @public * @instance * * @template {string} T * Candidate choice * * @return {Set} * The list of candidate choices */ choices(): Set; /** * Set the default value configuration. * * @see {@linkcode DefaultInfo} * * @public * @instance * * @param {DefaultInfo | null | undefined} info * The default value info * @return {this} * `this` candidate */ default(info: DefaultInfo | null | undefined): this; /** * Get the default value configuration. * * @see {@linkcode DefaultInfo} * * @public * @instance * * @template {any} T * The default value * * @return {DefaultInfo | undefined} * The default value info */ default(): DefaultInfo | undefined; /** * Set the handler used to parse candidate-arguments. * * @see {@linkcode ParseArg} * * @public * @instance * * @param {ParseArg | null | undefined} parser * The argument parser * @return {this} * `this` candidate */ parser(parser: ParseArg | null | undefined): this; /** * Get the handler used to parse candidate-arguments. * * @see {@linkcode ParseArg} * * @public * @instance * * @template {any} T * The result of the parse * @template {any} [Previous=T] * The previous parse result * * @return {ParseArg} * The argument parser */ parser(): ParseArg; /** * Get the candidate as a human-readable string. * * @public * @abstract * @instance * @override * * @return {string} * String representation of `this` candidate */ abstract toString(): string; } export default Parseable;