import { z } from 'zod'; import { ArgsObject } from './command'; export declare const OptionConfig: (type: z.ZodType) => z.ZodObject<{ name: z.ZodString; description: z.ZodString; defaultValue: z.ZodOptional; aliases: z.ZodArray; parse: z.ZodOptional>>; array: z.ZodOptional; required: z.ZodOptional; isDefault: z.ZodOptional; hidden: z.ZodOptional; outputName: z.ZodOptional; }, z.core.$strip>; export type OptionConfig = z.infer>>; /** * Configuration for a flag (boolean argument) that can be passed to a command. */ export declare const FlagConfig: z.ZodObject<{ name: z.ZodString; description: z.ZodString; defaultValue: z.ZodOptional; aliases: z.ZodArray; array: z.ZodOptional; required: z.ZodOptional; hidden: z.ZodOptional; outputName: z.ZodOptional; negatable: z.ZodOptional; negationName: z.ZodOptional; negationAliases: z.ZodOptional>; }, z.core.$strip>; export type FlagConfig = z.infer; /** * A function that parses an option value. */ export type Parser = (x: string, y: Args) => OptionType; /** {@link OptionConfig} with a specified value type */ export declare const TypedOptionConfig: (type: z.ZodType) => z.ZodObject<{ name: z.ZodString; description: z.ZodString; defaultValue: z.ZodOptional; aliases: z.ZodArray; parse: z.ZodOptional, unknown, z.core.$ZodTypeInternals, unknown>>>; array: z.ZodOptional; required: z.ZodOptional; isDefault: z.ZodOptional; hidden: z.ZodOptional; outputName: z.ZodOptional; type: z.ZodOptional>; }, z.core.$strip>; export type TypedOptionConfig = z.infer>>; /** * @see OptionConfig * @see ArrayOptionConfig */ export declare const ArrayOptionConfig: (type: z.ZodType) => z.ZodObject<{ name: z.ZodString; description: z.ZodString; aliases: z.ZodArray; parse: z.ZodOptional, unknown, z.core.$ZodTypeInternals, unknown>>>; array: z.ZodOptional; required: z.ZodOptional; isDefault: z.ZodOptional; hidden: z.ZodOptional; outputName: z.ZodOptional; type: z.ZodOptional>; defaultValue: z.ZodOptional>>>; }, z.core.$strip>; /** * An option that can be passed to a command. * * This type represents an array option, which can be specified multiple times. */ export type ArrayOptionConfig = z.infer>>>; /** The default prefixes for options */ export declare const DEFAULT_OPT_FULL_PREFIX = "--"; /** The default prefix for option aliases */ export declare const DEFAULT_OPT_SHORT_PREFIX = "-"; export type Prefixes = { normalPrefix: string; aliasPrefix: string; }; export type Names = { name: string; aliases: string[]; }; /** Names with prefixes built-in */ export type QualifiedNames = { name: string; aliases: string[]; negationName: string; negationAliases: string[]; }; /** @internal */ export type ArgvValue = { argv: string[]; value: T; key: string; }; /** * An option that can be passed to a command. * * Options can be specified in two ways: * * - Using the long form, e.g. `--option value` * - Using the short form, e.g. `-o value` * * They can also have a parse function, which will be used to parse the value passed in from the * original argument (string). * * @example * ```ts * massarg(options).option({ * name: 'option', * description: 'An option', * defaultValue: 'default', * aliases: ['o'], * parse: (value) => value.toUpperCase(), * }) * ``` */ export declare class MassargOption implements OptionConfig { name: string; description: string; defaultValue?: OptionType; aliases: string[]; parse: Parser; /** * Whether this option can be used multiple times. Any passed values will end up in an array * instead of each usage overwriting the existing value. */ isArray: boolean; /** Whether this option is required. Failing to specify this option will throw an error. */ isRequired: boolean; isDefault: boolean; outputName?: string; constructor(options: OptionConfig); /** * Create a typed option from a configuration. Currently supports `number` options which * are automatically transformed from `string` to `number`. */ static fromTypedConfig(config: TypedOptionConfig): MassargOption; /** * Returns the key which this option outputs to in the final object. * * @default The camelCase version of this option's name. * * Can be overridden with {@link outputName}. */ getOutputName(): string; /** @internal */ parseDetails(argv: string[], options: ArgsObject, prefixes: Prefixes): ArgvValue; /** Get the help string for this option */ helpString(): string; /** Returns true if the flag (including any prefixes) matches the name or aliases */ isMatch(arg: string, prefixes: Prefixes): boolean; /** Return the finalized names that will cause this option to match. */ qualifiedNames(prefixes: Prefixes): QualifiedNames; } /** * An option that can be passed to a command. * * This type of option parses a number, and fails if it is not a valid number. * * @example * ```ts * massarg(options).option({ * name: 'number', * description: 'A number', * defaultValue: 0, * aliases: ['n'], * type: 'number', * }) * ``` */ export declare class MassargNumber extends MassargOption { constructor(options: Omit, 'parse'>); parseDetails(argv: string[], options: ArgsObject, prefixes: Prefixes): ArgvValue; } /** * A boolean option that can be passed to a command. * * A flag is an option that is either present or not. It can be used to toggle * a boolean value, or to indicate that a command should be run in a different * mode. * * A flag can be negated by using `negatable: true`. By default, the negated name is the same * as the option name, prefixed by `no-`, and each of the aliases will be uppercased. * For example, `--verbose` and `--no-verbose`, or `-v` and `-V`. * This behavior can be overridden by the `negatedName` and `negatedAliases` options. * * @example * ```ts * massarg.flag({ * name: 'verbose', * aliases: ['v'], * description: 'Enable verbose logging', * defaultValue: false, * }) * ``` */ export declare class MassargFlag extends MassargOption { /** Whether this flag may be negated using `negationName` or `negationAliases`. */ negatable: boolean; /** The negation name of this flag, which can be used with the full option notation. */ negationName: string; /** The negation aliases of this flag, which can be used with the shorthand option notation. */ negationAliases: string[]; constructor(options: FlagConfig); parseDetails(argv: string[], _options: ArgsObject, prefixes: Prefixes): ArgvValue; qualifiedNames(prefixes: Prefixes): QualifiedNames; } /** A flag that can be passed to a command to show the help message. */ export declare class MassargHelpFlag extends MassargFlag { constructor(config?: Partial, 'parse'>>); } //# sourceMappingURL=option.d.ts.map