New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cmd-ts

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cmd-ts - npm Package Compare versions

Comparing version 0.12.1 to 0.13.0

7

dist/cjs/multioption.d.ts

@@ -1,6 +0,7 @@

import { ArgParser } from './argparser';
import { ArgParser, Register } from './argparser';
import { OutputOf } from './from';
import { ProvidesHelp, LongDoc, ShortDoc, Descriptive } from './helpdoc';
import { Type, HasType } from './type';
declare type MultiOptionConfig<Decoder extends Type<string[], any>> = HasType<Decoder> & LongDoc & Partial<ShortDoc & Descriptive>;
import { Default } from './default';
declare type MultiOptionConfig<Decoder extends Type<string[], any>> = HasType<Decoder> & LongDoc & Partial<ShortDoc & Descriptive & Default<OutputOf<Decoder>>>;
/**

@@ -10,3 +11,3 @@ * Like `option`, but can accept multiple options, and expects a decoder from a list of strings.

*/
export declare function multioption<Decoder extends Type<string[], any>>(config: MultiOptionConfig<Decoder>): ArgParser<OutputOf<Decoder>> & ProvidesHelp;
export declare function multioption<Decoder extends Type<string[], any>>(config: MultiOptionConfig<Decoder>): ArgParser<OutputOf<Decoder>> & ProvidesHelp & Register;
export {};

@@ -25,2 +25,5 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -30,2 +33,3 @@ exports.multioption = void 0;

const Result = __importStar(require("./Result"));
const chalk_1 = __importDefault(require("chalk"));
/**

@@ -38,3 +42,3 @@ * Like `option`, but can accept multiple options, and expects a decoder from a list of strings.

helpTopics() {
var _a, _b;
var _a, _b, _c, _d;
const displayName = (_a = config.type.displayName) !== null && _a !== void 0 ? _a : 'value';

@@ -45,2 +49,16 @@ let usage = `--${config.long} <${displayName}>`;

}
const defaults = [];
const defaultValueFn = (_b = config.defaultValue) !== null && _b !== void 0 ? _b : config.type.defaultValue;
if (defaultValueFn) {
try {
const defaultValue = defaultValueFn();
if ((_c = config.defaultValueIsSerializable) !== null && _c !== void 0 ? _c : config.type.defaultValueIsSerializable) {
defaults.push('default: ' + chalk_1.default.italic(defaultValue));
}
else {
defaults.push('[...optional]');
}
}
catch (e) { }
}
return [

@@ -50,4 +68,4 @@ {

usage,
defaults: [],
description: (_b = config.description) !== null && _b !== void 0 ? _b : 'self explanatory',
defaults,
description: (_d = config.description) !== null && _d !== void 0 ? _d : 'self explanatory',
},

@@ -63,3 +81,3 @@ ];

async parse({ nodes, visitedNodes, }) {
var _a;
var _a, _b;
const options = (0, findOption_1.findOption)(nodes, {

@@ -69,2 +87,19 @@ longNames: [config.long],

}).filter((x) => !visitedNodes.has(x));
const defaultValueFn = (_a = config.defaultValue) !== null && _a !== void 0 ? _a : config.type.defaultValue;
if (options.length === 0 && typeof defaultValueFn === 'function') {
try {
return Result.ok(defaultValueFn());
}
catch (e) {
const message = `Failed to resolve default value for '--${config.long}': ${e.message}`;
return Result.err({
errors: [
{
nodes: [],
message,
},
],
});
}
}
for (const option of options) {

@@ -77,3 +112,3 @@ visitedNodes.add(option);

for (const option of options) {
const providedValue = (_a = option.value) === null || _a === void 0 ? void 0 : _a.node.raw;
const providedValue = (_b = option.value) === null || _b === void 0 ? void 0 : _b.node.raw;
if (providedValue === undefined) {

@@ -80,0 +115,0 @@ flagNodes.push(option);

@@ -1,6 +0,7 @@

import { ArgParser } from './argparser';
import { ArgParser, Register } from './argparser';
import { OutputOf } from './from';
import { ProvidesHelp, LongDoc, ShortDoc, Descriptive } from './helpdoc';
import { Type, HasType } from './type';
declare type MultiOptionConfig<Decoder extends Type<string[], any>> = HasType<Decoder> & LongDoc & Partial<ShortDoc & Descriptive>;
import { Default } from './default';
declare type MultiOptionConfig<Decoder extends Type<string[], any>> = HasType<Decoder> & LongDoc & Partial<ShortDoc & Descriptive & Default<OutputOf<Decoder>>>;
/**

@@ -10,3 +11,3 @@ * Like `option`, but can accept multiple options, and expects a decoder from a list of strings.

*/
export declare function multioption<Decoder extends Type<string[], any>>(config: MultiOptionConfig<Decoder>): ArgParser<OutputOf<Decoder>> & ProvidesHelp;
export declare function multioption<Decoder extends Type<string[], any>>(config: MultiOptionConfig<Decoder>): ArgParser<OutputOf<Decoder>> & ProvidesHelp & Register;
export {};
import { findOption } from './newparser/findOption';
import * as Result from './Result';
import chalk from 'chalk';
/**

@@ -10,3 +11,3 @@ * Like `option`, but can accept multiple options, and expects a decoder from a list of strings.

helpTopics() {
var _a, _b;
var _a, _b, _c, _d;
const displayName = (_a = config.type.displayName) !== null && _a !== void 0 ? _a : 'value';

@@ -17,2 +18,16 @@ let usage = `--${config.long} <${displayName}>`;

}
const defaults = [];
const defaultValueFn = (_b = config.defaultValue) !== null && _b !== void 0 ? _b : config.type.defaultValue;
if (defaultValueFn) {
try {
const defaultValue = defaultValueFn();
if ((_c = config.defaultValueIsSerializable) !== null && _c !== void 0 ? _c : config.type.defaultValueIsSerializable) {
defaults.push('default: ' + chalk.italic(defaultValue));
}
else {
defaults.push('[...optional]');
}
}
catch (e) { }
}
return [

@@ -22,4 +37,4 @@ {

usage,
defaults: [],
description: (_b = config.description) !== null && _b !== void 0 ? _b : 'self explanatory',
defaults,
description: (_d = config.description) !== null && _d !== void 0 ? _d : 'self explanatory',
},

@@ -35,3 +50,3 @@ ];

async parse({ nodes, visitedNodes, }) {
var _a;
var _a, _b;
const options = findOption(nodes, {

@@ -41,2 +56,19 @@ longNames: [config.long],

}).filter((x) => !visitedNodes.has(x));
const defaultValueFn = (_a = config.defaultValue) !== null && _a !== void 0 ? _a : config.type.defaultValue;
if (options.length === 0 && typeof defaultValueFn === 'function') {
try {
return Result.ok(defaultValueFn());
}
catch (e) {
const message = `Failed to resolve default value for '--${config.long}': ${e.message}`;
return Result.err({
errors: [
{
nodes: [],
message,
},
],
});
}
}
for (const option of options) {

@@ -49,3 +81,3 @@ visitedNodes.add(option);

for (const option of options) {
const providedValue = (_a = option.value) === null || _a === void 0 ? void 0 : _a.node.raw;
const providedValue = (_b = option.value) === null || _b === void 0 ? void 0 : _b.node.raw;
if (providedValue === undefined) {

@@ -52,0 +84,0 @@ flagNodes.push(option);

{
"name": "cmd-ts",
"version": "0.12.1",
"version": "0.13.0",
"homepage": "https://cmd-ts.now.sh",

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc