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

@kearisp/cli

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kearisp/cli - npm Package Compare versions

Comparing version 2.0.6 to 2.0.7-dev.0

7

lib/makes/Command.d.ts

@@ -1,2 +0,2 @@

import { Option } from "../types";
import { Option, OptionValue } from "../types";
import { CommandInput } from "./CommandInput";

@@ -21,2 +21,5 @@ type HelpParams = false | {

protected _options: Option[];
protected __options: {
[name: string]: OptionParams;
};
protected _action: Action;

@@ -26,3 +29,3 @@ protected _completions: Completion[];

get name(): string;
protected getCommandInput(args: any, options: any): CommandInput;
protected getCommandInput(params: any, optionValues?: OptionValue[]): CommandInput;
option(name: string, params: OptionParams): this;

@@ -29,0 +32,0 @@ protected getOptionSettings(name?: string, alias?: string): Option;

@@ -12,2 +12,3 @@ "use strict";

this._options = [];
this.__options = {};
this._completions = [];

@@ -20,12 +21,4 @@ this._command = command;

}
getCommandInput(args, options) {
const _this = this;
return new class extends CommandInput_1.CommandInput {
getParamSettings() {
return [];
}
getOptionSettings() {
return _this._options;
}
}(args, options);
getCommandInput(params, optionValues = []) {
return new CommandInput_1.CommandInput(params, optionValues);
}

@@ -48,2 +41,3 @@ option(name, params) {

];
this.__options[name] = params;
return this;

@@ -92,3 +86,3 @@ }

const args = {};
const options = {};
const optionValues = [];
const parser = new Parser_1.Parser(parts);

@@ -128,11 +122,20 @@ for (let i = 0; i < commands.length; i++) {

case "boolean":
options[option.name] = true;
optionValues.push({
name: option.name,
value: true
});
break;
case "number":
parser.next();
options[option.name] = parseFloat(parser.part);
optionValues.push({
name: option.name,
value: parseFloat(parser.part)
});
break;
case "string":
parser.next();
options[option.name] = parser.part;
optionValues.push({
name: option.name,
value: parser.part
});
break;

@@ -148,9 +151,18 @@ }

case "boolean":
options[option.name] = true;
optionValues.push({
name: option.name,
value: true
});
break;
case "number":
options[option.name] = parseFloat(value);
optionValues.push({
name: option.name,
value: parseFloat(value)
});
break;
case "string":
options[option.name] = value;
optionValues.push({
name: option.name,
value
});
break;

@@ -164,3 +176,6 @@ }

if (option && option.type === "boolean") {
options[option.name] = true;
optionValues.push({
name: option.name,
value: true
});
}

@@ -175,3 +190,3 @@ });

}
return this.getCommandInput(args, options);
return this.getCommandInput(args, optionValues);
}

@@ -335,2 +350,3 @@ async emit(name, input) {

const options = {};
const optionValues = [];
for (const command of commands) {

@@ -347,3 +363,3 @@ if (parser.isSpread(command)) {

args[name] = value;
return this.predictCommand(command, parser.part, this.getCommandInput(args, options));
return this.predictCommand(command, parser.part, this.getCommandInput(args, optionValues));
}

@@ -362,3 +378,3 @@ else if (!parser.isLast && parser.isCommand(command)) {

}
return this.predictCommand(command, parser.part, this.getCommandInput(args, options));
return this.predictCommand(command, parser.part, this.getCommandInput(args, optionValues));
}

@@ -389,2 +405,6 @@ else {

options[option.name] = true;
optionValues.push({
name: option.name,
value: true
});
break;

@@ -408,3 +428,3 @@ case "string":

}
const predicts = await completion.action(this.getCommandInput(args, options));
const predicts = await completion.action(this.getCommandInput(args, optionValues));
return predicts.map((predict) => {

@@ -418,2 +438,6 @@ if (sign === "=") {

options[option.name] = v;
optionValues.push({
name: option.name,
value: v
});
break;

@@ -420,0 +444,0 @@ }

@@ -1,12 +0,10 @@

import { Option, Param } from "../types";
import { OptionValue } from "../types";
export declare class CommandInput {
protected readonly _arguments: any;
protected readonly _options: any;
constructor(_arguments: any, _options: any);
protected getParamSettings(): Param[];
protected getOptionSettings(): Option[];
argument(key: string): null | string;
protected readonly _options: OptionValue[];
constructor(_arguments: any, _options: OptionValue[]);
argument(key: string): string | undefined;
arguments(): any;
option<T extends null | string | boolean>(key: string, defaultValue?: T): T;
options(): any;
option(key: string, defaultValue?: any): any;
options(key?: string): any[];
}

@@ -9,8 +9,2 @@ "use strict";

}
getParamSettings() {
return [];
}
getOptionSettings() {
return [];
}
argument(key) {

@@ -20,3 +14,3 @@ if (key in this._arguments) {

}
return null;
return undefined;
}

@@ -26,12 +20,19 @@ arguments() {

}
option(key, defaultValue = null) {
if (key in this._options) {
return this._options[key];
option(key, defaultValue) {
const optionValue = this._options.find((option) => {
return option.name === key;
});
if (!optionValue) {
return defaultValue;
}
return defaultValue;
return optionValue.value;
}
options() {
return this._options;
options(key) {
return this._options.filter((option) => {
return option.name === key;
}).map((option) => {
return option.value;
});
}
}
exports.CommandInput = CommandInput;
export type Option = {
name: string;
type: "string" | "boolean" | "number";
type: "boolean" | "number" | "string";
help?: boolean;
alias?: string;
description?: string;
default?: string | boolean | number;
default?: boolean | string | number;
};
export type OptionValue = {
name: string;
value: boolean | string | number;
};
{
"name": "@kearisp/cli",
"version": "2.0.6",
"version": "2.0.7-dev.0",
"license": "MIT",

@@ -26,3 +26,3 @@ "author": "Kris Papercut <krispcut@gmail.com>",

"test": "KP_LOG=disable jest --colors --no-coverage",
"test-watch": "jest --colors --watchAll",
"test-watch": "jest --colors --coverage --no-cache --watchAll",
"test-watch:cli": "jest --colors --watchAll --runTestsByPath ./src/makes/Cli.spec.ts",

@@ -37,3 +37,3 @@ "test-watch:command": "jest --colors --watchAll --runTestsByPath ./src/makes/Command.spec.ts",

"devDependencies": {
"@types/jest": "^29.5.12",
"@types/jest": "^29.5.14",
"@types/node": "^20.12.7",

@@ -44,4 +44,4 @@ "fs": "^0.0.1-security",

"ts-node": "^10.9.2",
"typescript": "^5.6.2"
"typescript": "^5.6.3"
}
}
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