@oclif/core
Advanced tools
+18
-0
@@ -39,1 +39,19 @@ import { URL } from 'node:url'; | ||
| export { stringArg as string }; | ||
| type ReadonlyElementOf<T extends ReadonlyArray<unknown>> = T[number]; | ||
| /** | ||
| * Create an arg that infers the type from the provided options. | ||
| * | ||
| * The provided `options` must be a readonly array in order for type inference to work. | ||
| * | ||
| * @example | ||
| * export default class MyCommand extends Command { | ||
| * static args = { | ||
| * stage: Args.option({ | ||
| * options: ['production', 'staging', 'development'] as const, | ||
| * })(), | ||
| * } | ||
| * } | ||
| */ | ||
| export declare function option<T extends readonly string[]>(defaults: Omit<Partial<Arg<ReadonlyElementOf<T>>>, 'default' | 'multiple' | 'required'> & { | ||
| options: T; | ||
| }): ArgDefinition<(typeof defaults.options)[number]>; |
+24
-0
@@ -5,2 +5,3 @@ "use strict"; | ||
| exports.custom = custom; | ||
| exports.option = option; | ||
| const node_url_1 = require("node:url"); | ||
@@ -63,1 +64,24 @@ const fs_1 = require("./util/fs"); | ||
| exports.string = stringArg; | ||
| /** | ||
| * Create an arg that infers the type from the provided options. | ||
| * | ||
| * The provided `options` must be a readonly array in order for type inference to work. | ||
| * | ||
| * @example | ||
| * export default class MyCommand extends Command { | ||
| * static args = { | ||
| * stage: Args.option({ | ||
| * options: ['production', 'staging', 'development'] as const, | ||
| * })(), | ||
| * } | ||
| * } | ||
| */ | ||
| function option(defaults) { | ||
| return (options = {}) => ({ | ||
| parse: async (i, _context, _opts) => i, | ||
| ...defaults, | ||
| ...options, | ||
| input: [], | ||
| type: 'option', | ||
| }); | ||
| } |
@@ -201,3 +201,3 @@ import { Command } from '../command'; | ||
| multiple?: boolean; | ||
| options?: string[]; | ||
| options?: readonly string[]; | ||
| ignoreStdin?: boolean; | ||
@@ -248,3 +248,3 @@ /** | ||
| export type Arg<T, P = CustomOptions> = ArgProps & { | ||
| options?: T[]; | ||
| options?: readonly T[]; | ||
| defaultHelp?: ArgDefaultHelp<T>; | ||
@@ -251,0 +251,0 @@ input: string[]; |
+1
-1
| { | ||
| "name": "@oclif/core", | ||
| "description": "base library for oclif CLIs", | ||
| "version": "4.11.14", | ||
| "version": "4.12.0", | ||
| "author": "Salesforce", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/oclif/core/issues", |
459100
0.28%11422
0.37%