@replit/clui-input
Advanced tools
Comparing version
@@ -105,2 +105,15 @@ "use strict"; | ||
}; | ||
var pasrseValue = function (_a) { | ||
var value = _a.value, type = _a.type; | ||
switch (type) { | ||
case 'boolean': | ||
return !!value; | ||
case 'int': | ||
return parseInt(value, 10); | ||
case 'float': | ||
return parseFloat(value); | ||
default: | ||
return value; | ||
} | ||
}; | ||
exports.toArgs = function (command) { | ||
@@ -123,3 +136,5 @@ var e_3, _a, e_4, _b; | ||
if (str) { | ||
var value = arg.ref.type ? arg.ref.type(str) : str; | ||
var value = arg.ref.type | ||
? pasrseValue({ value: str, type: arg.ref.type }) | ||
: str; | ||
parsed[arg.key.name] = | ||
@@ -126,0 +141,0 @@ typeof value === 'string' ? removeQuotes(value) : value; |
@@ -89,3 +89,3 @@ "use strict"; | ||
var argNode = void 0; | ||
if (argCtx.type === Boolean) { | ||
if (argCtx.type === 'boolean') { | ||
argNode = { | ||
@@ -92,0 +92,0 @@ parent: cmdNodeCtx, |
@@ -8,3 +8,3 @@ export interface IOption<D = any> { | ||
} | ||
export declare type ArgTypeDef = BooleanConstructor | StringConstructor | NumberConstructor; | ||
export declare type ArgTypeDef = 'boolean' | 'string' | 'int' | 'float'; | ||
export interface IArgsOption { | ||
@@ -11,0 +11,0 @@ value: string; |
{ | ||
"name": "@replit/clui-input", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "A utility library for building CLI style interfaces with autocomplete", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
75932
3.23%23
4.55%1183
1.28%1
-50%70
Infinity%