Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cli-flags

Package Overview
Dependencies
Maintainers
3
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-flags - npm Package Compare versions

Comparing version 1.0.17 to 1.0.18

7

lib/args.d.ts

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

export declare type ArgParseContext<T = string> = {
arg: Arg<T>;
} & {
[k: string]: any;
};
export declare type ParseFn<T> = (input: string, parseContext: ArgParseContext<T>) => T;
export declare type ParseFn<T> = (input: string) => T;
export interface IArg<T = string> {

@@ -8,0 +3,0 @@ name: string;

22

lib/flags.d.ts
import { AlphabetLowercase, AlphabetUppercase } from './alphabet';
import { ParserInput } from './parse';
export declare type DefaultContext<T> = {
options: IOptionFlag<T>;
flags: {
[k: string]: string;
};
};
export interface IFlagBase {

@@ -13,22 +18,13 @@ name: string;

allowNo: boolean;
input: string;
}
export declare type ParseContext = {
[k: string]: any;
};
export declare type FlagParseContext<T, PC extends ParseContext> = {
flag: IOptionFlag<T>;
input: ParserInput;
} & PC;
export declare type ParseFn<T, PC = any> = (input: string, parseContext: FlagParseContext<T, PC>) => T;
export interface IOptionFlagBase<T> extends IFlagBase {
type: 'option';
parse: ParseFn<T>;
input: string[];
parse: (input: string) => T;
}
export interface IOptionalFlag<T> extends IOptionFlagBase<T> {
multiple: false;
default?: T | ((context: ParseContext) => T);
default?: T | ((context: DefaultContext<T>) => T | undefined);
}
export interface IRequiredFlag<T> extends IOptionFlagBase<T> {
required: true;
multiple: false;

@@ -35,0 +31,0 @@ default?: undefined;

@@ -17,6 +17,3 @@ export { IArg } from './args';

strict?: boolean;
parseContext?: {
[k: string]: any;
};
};
export declare function parse(options: ParserInput): ParserOutput;

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

flags: Object.assign({ color: deps_1.deps.flags.defaultFlags.color }, (options.flags || {})),
parseContext: options.parseContext || {},
strict: options.strict !== false,

@@ -16,0 +15,0 @@ };

@@ -32,5 +32,2 @@ import { Arg } from './args';

strict: boolean;
parseContext: {
[k: string]: any;
};
};

@@ -37,0 +34,0 @@ export declare class Parser {

@@ -57,7 +57,5 @@ "use strict";

}
flag.input.push(input);
this.raw.push({ type: 'flag', flag: flag.name, input });
}
else {
flag.input = arg;
this.raw.push({ type: 'flag', flag: flag.name, input: arg });

@@ -121,3 +119,3 @@ if (!long && arg.length > 2) {

else {
const value = flag.parse(token.input, Object.assign({ flag }, this.input.parseContext));
const value = flag.parse(token.input);
if (flag.multiple) {

@@ -136,3 +134,3 @@ flags[token.flag] = flags[token.flag] || [];

if (typeof flag.default === 'function') {
flags[k] = flag.default({ flag, input: this.input });
flags[k] = flag.default({ options: flag, flags });
}

@@ -155,3 +153,3 @@ else {

if (arg) {
args[i] = arg.parse(token.input, Object.assign({ arg }, this.input.parseContext));
args[i] = arg.parse(token.input);
}

@@ -158,0 +156,0 @@ else {

{
"name": "cli-flags",
"description": "basic CLI flag parser",
"version": "1.0.17",
"version": "1.0.18",
"author": "Jeff Dickey",

@@ -6,0 +6,0 @@ "bugs": "https://github.com/heroku/cli-flags/issues",

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