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

@anycli/command

Package Overview
Dependencies
Maintainers
3
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@anycli/command - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

9

CHANGELOG.md

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

<a name="1.2.4"></a>
## [1.2.4](https://github.com/anycli/command/compare/a002c7c2e3f54a0a0bd37b4844ceea5d815d69f6...v1.2.4) (2018-02-03)
### Bug Fixes
* fixed init hook arguments ([26895f7](https://github.com/anycli/command/commit/26895f7))
* help improvements ([93b8f8d](https://github.com/anycli/command/commit/93b8f8d))
<a name="1.2.3"></a>

@@ -2,0 +11,0 @@ ## [1.2.3](https://github.com/anycli/command/compare/13a6193a1e2c577b3eaa49c6f38d2326eb40eea9...v1.2.3) (2018-02-03)

3

lib/command.d.ts

@@ -48,2 +48,5 @@ import * as Config from '@anycli/config';

protected finally(_: Error | undefined): Promise<void>;
protected _help(): void;
protected _helpOverride(): boolean;
protected _version(): void;
}

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

global['http-call'].userAgent = this.config.userAgent;
await this.config.runHook('init', { argv: this.argv });
if (this._helpOverride())
return this._help();
}

@@ -50,3 +53,10 @@ parse(options, argv = this.argv) {

async catch(err) {
cli_ux_1.default.error(err);
if (err.message.match(/Unexpected arguments?: (-h|--help)(,|\n)/)) {
this._help();
}
else if (err.message.match(/Unexpected arguments?: (-v|--version)(,|\n)/)) {
this._version();
}
else
cli_ux_1.default.error(err);
}

@@ -61,2 +71,23 @@ async finally(_) {

}
_help() {
const HHelp = require('@anycli/plugin-help').default;
const help = new HHelp(this.config);
help.showHelp(this.argv);
cli_ux_1.default.exit(0);
}
_helpOverride() {
if (this.argv[0] === '--version' || this.argv[0] === 'version')
this._version();
for (let arg of this.argv) {
if (arg === '--help')
return true;
if (arg === '--')
return false;
}
return false;
}
_version() {
cli_ux_1.default.info(this.config.userAgent);
cli_ux_1.default.exit(0);
}
}

@@ -63,0 +94,0 @@ Command._base = `${pjson.name}@${pjson.version}`;

13

lib/flags.js

@@ -26,10 +26,17 @@ "use strict";

exports.version = (opts = {}) => {
return Parser.flags.boolean(Object.assign({ char: 'v', description: 'show CLI version' }, opts, { parse: (_, cmd) => {
return Parser.flags.boolean(Object.assign({
// char: 'v',
description: 'show CLI version' }, opts, { parse: (_, cmd) => {
cli_ux_1.default.info(cmd.config.userAgent);
cli_ux_1.default.exit(0);
} }));
};
exports.help = (opts = {}) => {
return Parser.flags.boolean(Object.assign({ char: 'h', description: 'show CLI help' }, opts, { parse: (_, cmd) => {
cli_ux_1.default.info(cmd);
return Parser.flags.boolean(Object.assign({
// char: 'h',
description: 'show CLI help' }, opts, { parse: (_, cmd) => {
const HHelp = require('@anycli/plugin-help').default;
const help = new HHelp(cmd.config);
cli_ux_1.default.info(help);
} }));
};
import * as Config from '@anycli/config';
import { Command } from '.';
export declare class Main extends Command {
static parserOptions: {
'--': boolean;
strict: boolean;
static flags: {
version: {
name: string;
char?: "a" | "b" | "i" | "p" | "q" | "s" | "u" | "g" | "c" | "d" | "e" | "f" | "h" | "j" | "k" | "l" | "m" | "n" | "o" | "r" | "t" | "v" | "x" | "y" | "z" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "X" | "Y" | "Z" | undefined;
description?: string | undefined;
hidden?: boolean | undefined;
required?: boolean | undefined;
env?: string | undefined;
parse(input: boolean, context: any): void;
} & {
type: "boolean";
allowNo: boolean;
};
help: {
name: string;
char?: "a" | "b" | "i" | "p" | "q" | "s" | "u" | "g" | "c" | "d" | "e" | "f" | "h" | "j" | "k" | "l" | "m" | "n" | "o" | "r" | "t" | "v" | "x" | "y" | "z" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "X" | "Y" | "Z" | undefined;
description?: string | undefined;
hidden?: boolean | undefined;
required?: boolean | undefined;
env?: string | undefined;
parse(input: boolean, context: any): void;
} & {
type: "boolean";
allowNo: boolean;
};
};
static run(argv?: string[], options?: Config.Options): Promise<any>;
run(): Promise<void>;
protected _helpOverride(): boolean;
}
export declare function run(argv?: string[], options?: Config.Options): Promise<any>;

@@ -9,7 +9,26 @@ "use strict";

async run() {
const [id, ...argv] = this.argv;
let [id, ...argv] = this.argv;
this.parse(Object.assign({ strict: false, '--': false }, this.ctor));
await this.config.runCommand(id, argv);
}
_helpOverride() {
if (['-v', '--version', 'version'].includes(this.argv[0]))
return this._version();
if (this.argv[0] === '-h')
return true;
if (this.argv.length === 0)
return true;
for (let arg of this.argv) {
if (arg === '--help')
return true;
if (arg === '--')
return false;
}
return false;
}
}
Main.parserOptions = { '--': false, strict: false };
Main.flags = {
version: _1.flags.version(),
help: _1.flags.help(),
};
exports.Main = Main;

@@ -16,0 +35,0 @@ function run(argv = process.argv.slice(2), options) {

{
"name": "@anycli/command",
"description": "anycli base command",
"version": "1.2.3",
"version": "1.2.4",
"author": "Jeff Dickey @jdxcode",
"bugs": "https://github.com/anycli/command/issues",
"anycli": {
"scope": "anycli",
"devPlugins": [
"@anycli/plugin-plugins",
"@anycli/plugin-not-found",
"@anycli/plugin-help"
]
},
"dependencies": {

@@ -16,4 +24,6 @@ "@anycli/parser": "^3.2.2",

"devDependencies": {
"@anycli/config": "^1.0.17",
"@anycli/plugin-help": "^0.5.0",
"@anycli/config": "^1.1.2",
"@anycli/plugin-help": "^0.6.0",
"@anycli/plugin-not-found": "^0.1.15",
"@anycli/plugin-plugins": "^0.2.11",
"@anycli/tslint": "^0.2.5",

@@ -20,0 +30,0 @@ "@types/chai": "^4.1.2",

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