makfy
Advanced tools
Comparing version 2.0.1 to 2.0.2
# makfy changelog | ||
## 2.0.2 | ||
- improved TypeScript support for enum arguments (thanks to SanderRonde). | ||
## 2.0.1 | ||
@@ -4,0 +8,0 @@ |
import { Schema } from "jsonschema"; | ||
export declare const reservedArgNames: string[]; | ||
export interface FlagArgDefinition { | ||
export interface ArgDefinition { | ||
type: string; | ||
desc?: string; | ||
byDefault?: any; | ||
} | ||
export interface FlagArgDefinition extends ArgDefinition { | ||
type: "flag" | "f"; | ||
@@ -9,3 +14,3 @@ byDefault?: false; | ||
export declare const flagArgSchema: Schema; | ||
export interface StringArgDefinition { | ||
export interface StringArgDefinition extends ArgDefinition { | ||
type: "string" | "s"; | ||
@@ -16,11 +21,10 @@ byDefault?: string; | ||
export declare const stringArgSchema: Schema; | ||
export interface EnumArgDefinition { | ||
export interface EnumArgDefinition<V extends string> extends ArgDefinition { | ||
type: "enum" | "e"; | ||
values: string[]; | ||
byDefault?: string; | ||
values: V[]; | ||
byDefault?: V; | ||
desc?: string; | ||
} | ||
export declare const enumArgSchema: Schema; | ||
export declare type ArgDefinition = FlagArgDefinition | StringArgDefinition | EnumArgDefinition; | ||
export declare type ArgInstance<T extends ArgDefinition> = T extends FlagArgDefinition ? boolean : T extends StringArgDefinition ? string : T extends EnumArgDefinition ? string : string | boolean; | ||
export declare type ArgInstance<T extends ArgDefinition> = T extends FlagArgDefinition ? boolean : T extends StringArgDefinition ? string : T extends EnumArgDefinition<infer V> ? V : string | boolean; | ||
export declare const argSchema: Schema; | ||
@@ -27,0 +31,0 @@ export declare const argsSchema: Schema; |
@@ -120,3 +120,4 @@ "use strict"; | ||
var desc = argDescs[argName]; | ||
var argObj = (_this._command.args[argName] = _this._command.args[argName] || {}); | ||
var argObj = (_this._command.args[argName] = | ||
_this._command.args[argName] || {}); | ||
Object.assign(argObj, { desc: desc }); | ||
@@ -123,0 +124,0 @@ }); |
import { EnumArgDefinition, FlagArgDefinition, StringArgDefinition } from "./schema/args"; | ||
export declare function flag(): FlagArgDefinition; | ||
export declare function str(byDefault?: string): StringArgDefinition; | ||
export declare function choice(values: string[], byDefault?: string): EnumArgDefinition; | ||
export declare function choice<V extends string = string>(values: V[], byDefault?: V): EnumArgDefinition<V>; |
{ | ||
"name": "makfy", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "makfy - npm scripts on steroids!", | ||
@@ -5,0 +5,0 @@ "main": "dist/lib/index.js", |
Sorry, the diff of this file is not supported yet
173369
3529