@oclif/parser
- Version 3.8.17
- Published
- 36.3 kB
- 4 dependencies
- MIT license
Install
npm i @oclif/parser
yarn add @oclif/parser
pnpm add @oclif/parser
Overview
arg and flag parser for oclif
Index
Functions
function flagUsages
flagUsages: ( flags: IFlag<any>[], options?: FlagUsageOptions) => [string, string | undefined][];
function parse
parse: <TFlags, TArgs extends { [name: string]: string }>( argv: string[], options: Input<TFlags>) => Output<TFlags, TArgs>;
Type Aliases
type Input
type Input<TFlags extends flags.Output> = { flags?: flags.Input<TFlags>; args?: args.Input; strict?: boolean; context?: any; '--'?: boolean;};
type Output
type ParserOutput<TFlags extends OutputFlags<any>, TArgs extends OutputArgs> = { flags: TFlags; args: TArgs; argv: string[]; raw: ParsingToken[]; metadata: Metadata;};
type OutputArgs
type OutputArgs = { [name: string]: any;};
type OutputFlags
type OutputFlags<T extends ParserInput['flags']> = { [P in keyof T]: any;};
Namespaces
namespace args
module 'lib/args.d.ts' {}
function newArg
newArg: { <T>(arg: IArg<T> & { Parse: ParseFn<T> }): Arg<T>; (arg: IArg<string>): Arg<string>;};
interface ArgBase
interface ArgBase<T> {}
interface IArg
interface IArg<T = string> {}
interface Output
interface Output {}
index signature
[name: string]: any;
type Arg
type Arg<T> = RequiredArg<T> | OptionalArg<T>;
type Input
type Input = IArg<any>[];
type OptionalArg
type OptionalArg<T> = ArgBase<T> & { required: false; value?: T;};
type ParseFn
type ParseFn<T> = (input: string) => T;
type RequiredArg
type RequiredArg<T> = ArgBase<T> & { required: true; value: T;};
namespace flags
module 'lib/flags.d.ts' {}
also accept an environment variable as input
variable defaultFlags
const defaultFlags: { color: IBooleanFlag<boolean> };
variable integer
const integer: Definition<number>;
variable string
const string: Definition<string>;
function boolean
boolean: <T = boolean>(options?: Partial<IBooleanFlag<T>>) => IBooleanFlag<T>;
function build
build: { <T>( defaults: { parse: IOptionFlag<T>['parse'] } & Partial<IOptionFlag<T>> ): Definition<T>; (defaults: Partial<IOptionFlag<string>>): Definition<string>;};
function option
option: <T>( options: { parse: IOptionFlag<T>['parse'] } & Partial<IOptionFlag<T>>) => IOptionFlag<T | undefined>;
type Default
type Default<T> = T | ((context: DefaultContext<T>) => T);
type DefaultContext
type DefaultContext<T> = { options: IOptionFlag<T>; flags: { [k: string]: string; };};
type Definition
type Definition<T> = { ( options: { multiple: true; } & Partial<IOptionFlag<T[]>> ): IOptionFlag<T[]>; ( options: ( | { required: true; } | { default: Default<T>; } ) & Partial<IOptionFlag<T>> ): IOptionFlag<T>; (options?: Partial<IOptionFlag<T>>): IOptionFlag<T | undefined>;};
type EnumFlagOptions
type EnumFlagOptions<T> = Partial<IOptionFlag<T>> & { options: T[];};
type IBooleanFlag
type IBooleanFlag<T> = IFlagBase<T, boolean> & { type: 'boolean'; allowNo: boolean; /** * specifying a default of false is the same not specifying a default */ default?: Default<boolean>;};
type IFlag
type IFlag<T> = IBooleanFlag<T> | IOptionFlag<T>;
type IFlagBase
type IFlagBase<T, I> = { name: string; char?: AlphabetLowercase | AlphabetUppercase; description?: string; helpLabel?: string; hidden?: boolean; required?: boolean; dependsOn?: string[]; exclusive?: string[]; exactlyOne?: string[]; /** * also accept an environment variable as input */ env?: string; parse(input: I, context: any): T;};
type Input
type Input<T extends Output> = { [P in keyof T]: IFlag<T[P]>;};
type IOptionFlag
type IOptionFlag<T> = IFlagBase<T, string> & { type: 'option'; helpValue?: string; default?: Default<T | undefined>; multiple: boolean; input: string[]; options?: string[];};
type Output
type Output = { [name: string]: any;};
Package Files (5)
Dependencies (4)
Dev Dependencies (14)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@oclif/parser
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@oclif/parser)
- HTML<a href="https://www.jsdocs.io/package/@oclif/parser"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2942 ms. - Missing or incorrect documentation? Open an issue for this package.