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

cli-flags

Package Overview
Dependencies
Maintainers
1
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.0 to 1.0.1

lib/errors/unexpected_args.d.ts

11

lib/cli.js

@@ -11,5 +11,8 @@ "use strict";

function renderList(items) {
const S = require('string');
const max = require('lodash.maxby');
const maxLength = max(items, '[0].length')[0].length;
const padEnd = require('lodash.padend');
const maxBy = require('lodash.maxby');
if (items.length === 0) {
return '';
}
const maxLength = maxBy(items, '[0].length')[0].length;
const lines = items.map(i => {

@@ -21,3 +24,3 @@ let left = i[0];

}
left = `${S(left).padRight(maxLength)}`;
left = `${padEnd(left, maxLength)}`;
right = linewrap(maxLength + 2, right);

@@ -24,0 +27,0 @@ return `${left} ${right}`;

@@ -8,3 +8,3 @@ import { IArg } from './args';

export interface IInputOptions {
argv: string[];
argv?: string[];
flags?: InputFlags;

@@ -11,0 +11,0 @@ args?: IArg[];

@@ -83,3 +83,3 @@ "use strict";

function parse(options) {
const input = Object.assign({ args: [], flags: {} }, options);
const input = Object.assign({ args: [], argv: process.argv.slice(2), flags: {} }, options);
setNames(input.flags);

@@ -86,0 +86,0 @@ const arr = parseArray(input);

@@ -5,6 +5,8 @@ "use strict";

const required_flag_1 = require("./errors/required_flag");
const unexpected_args_1 = require("./errors/unexpected_args");
function validateArgs(expected, input) {
const maxArgs = expected.length;
if (input.length > maxArgs) {
throw new Error('whoa');
const extras = input.slice(maxArgs);
throw new unexpected_args_1.UnexpectedArgsError(extras);
}

@@ -11,0 +13,0 @@ const requiredArgs = expected.filter(a => a.required);

{
"name": "cli-flags",
"description": "basic CLI flag parser",
"version": "1.0.0",
"version": "1.0.1",
"author": "Jeff Dickey",
"bugs": "https://github.com/jdxcode/cli-flags/issues",
"dependencies": {
"@heroku/linewrap": "^1.0.0",
"lodash.maxby": "^4.6.0",
"lodash.padend": "^4.6.1"
},
"devDependencies": {
"@types/jest": "^20.0.8",
"@types/lodash.maxby": "^4.6.3",
"@types/lodash.padend": "^4.6.3",
"@types/node": "^8.0.28",

@@ -55,2 +61,3 @@ "husky": "^0.14.3",

"coverage": "cat coverage/coverage-final.json | remap-istanbul -o coverage/coverage-final.json && curl -s https://codecov.io/bash | bash",
"posttest": "tslint -p .",
"precommit": "lint-staged",

@@ -61,8 +68,3 @@ "prepare": "rimraf lib && tsc",

},
"types": "./lib/index.d.ts",
"dependencies": {
"@heroku/linewrap": "^1.0.0",
"lodash.maxby": "^4.6.0",
"string": "^3.3.3"
}
"types": "./lib/index.d.ts"
}

@@ -5,1 +5,29 @@ cli-flags

[![CircleCI](https://circleci.com/gh/jdxcode/cli-flags/tree/master.svg?style=svg)](https://circleci.com/gh/jdxcode/cli-flags/tree/master)
CLI flag parser.
Usage:
```js
const {flags: Flags, parse} = require('cli-flags')
const {flags, args} = parse({
flags: {
'output-file': Flags.string({char: 'o'}),
force: Flags.boolean({char: 'f'})
},
args: [
{name: 'input', required: true}
]
})
if (flags.force) {
console.log('--force was set')
}
if (flags['output-file']) {
console.log(`output file is: ${flags['output-file']}`)
}
console.log(`input arg: ${args.input}`)
```
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