UNPKG

meow-helper

Version:

Generate nicely formatted help text for meow CLI automatically.

60 lines 2.67 kB
import type { AnyFlag } from "meow"; /** Meow flag extended with `desc` key. */ export declare type ExtendedAnyFlag = AnyFlag & { desc?: string; }; /** Record of extended any flag. */ export declare type ExtendedAnyFlags = Record<string, ExtendedAnyFlag>; /** Options below modify behaviour of [[getHelp]] function. */ export interface HelpOptions { /** Text longer than line length will be word-wrapped. */ lineLength?: number; /** The total length of the colored background area of titles. */ titleLength?: number; /** `package.json` data. */ pkg?: Record<string, any>; /** Name of the command. */ command?: string; /** Command description. */ description?: string | string[]; /** Uasge text is shown at the beginning of help text. Lines are prefixed with `$` and command is colored automatically. */ usage?: string | string[]; /** Name and description of positional arguments. */ args?: Record<string, string>; /** Flags provided to meow. Uses `desc` key for the description. */ flags?: ExtendedAnyFlags; /** A single example or list of examples can be provided to show in the help text. Lines are prefixed with `$` and the command is colored automatically. */ examples?: string | string[]; /** If space available for option descriptions is less than this threshold, descriptions are given their own rows. So they have more space. See images above. */ multilineThreshold?: number; /** This option sets whether the `autoHelp` option of `meow` is used. If this is true, the description text is not added, because meow adds it automatically. */ autoHelp?: boolean; /** Whether to throw an error when `meow` exits with exit code 2. If true, it adds `process.on("exit")` to show help and exits with code 0. */ notThrow?: boolean; /** Option groups shown in help text. Key is the first option in group. */ groups?: Record<string, { title?: string; description?: string; }>; /** @ignore */ ui?: any; } /** * Assures output is an array by converting sets and single valiues into array. * * @param input is the input. * @returns the array. */ export declare function arrify<T>(input?: T | T[]): T[]; /** * Generate help text for meow. * * @param helpOptions are options * @example * const flags: ExtendedFlags = { cwd: { alias: "c", type: "string", desc: "Current CWD." }, ...commonFlags }; * const args = { path: "Path of file." }; * * meow(getHelp({flags, args, pkg}), { flags, pkg, allowUnknownFlags: false }); */ export default function getHelp(helpOptions: HelpOptions): string; //# sourceMappingURL=get-help.d.ts.map