cli-engine-command
Advanced tools
Comparing version 11.0.3 to 11.0.4
import { Config, ConfigOptions, Plugin } from 'cli-engine-config'; | ||
import { args } from 'cli-flags'; | ||
import { HTTP } from 'http-call'; | ||
import { args } from 'cli-flags'; | ||
import { IFlag } from './flags'; | ||
export declare type MockReturn<T extends Command> = { | ||
export interface IMockReturn<T extends Command> { | ||
cmd: T; | ||
stdout: string; | ||
stderr: string; | ||
}; | ||
export declare type CommandRunFn = <T extends Command>(this: CommandClass<T>, config?: ConfigOptions) => Promise<T>; | ||
export declare type CommandMockFn = <T extends Command>(this: CommandClass<T>, ...argv: string[]) => Promise<MockReturn<T>>; | ||
export interface CommandClass<T extends Command> { | ||
} | ||
export declare type CommandRunFn = <T extends Command>(this: ICommandClass<T>, config?: ConfigOptions) => Promise<T>; | ||
export declare type CommandMockFn = <T extends Command>(this: ICommandClass<T>, ...argv: string[]) => Promise<IMockReturn<T>>; | ||
export interface ICommandClass<T extends Command> { | ||
mock: CommandMockFn; | ||
run: CommandRunFn; | ||
new ({config}: { | ||
config?: ConfigOptions; | ||
}): T; | ||
run: CommandRunFn; | ||
mock: CommandMockFn; | ||
} | ||
export declare class Command { | ||
export declare abstract class Command { | ||
static topic: string; | ||
@@ -43,3 +43,4 @@ static command: string | undefined; | ||
static run: CommandRunFn; | ||
readonly ctor: typeof Command; | ||
static buildHelp(config: Config): string; | ||
static buildHelpLine(config: Config): [string, string | undefined]; | ||
config: Config; | ||
@@ -54,6 +55,2 @@ http: typeof HTTP; | ||
}; | ||
constructor(options?: { | ||
config?: ConfigOptions; | ||
}); | ||
init(): Promise<void>; | ||
topic: null; | ||
@@ -66,8 +63,11 @@ command: null; | ||
aliases: null; | ||
readonly ctor: typeof Command; | ||
constructor(options?: { | ||
config?: ConfigOptions; | ||
}); | ||
init(): Promise<void>; | ||
/** | ||
* actual command run code goes here | ||
*/ | ||
run(): Promise<void>; | ||
static buildHelp(config: Config): string; | ||
static buildHelpLine(config: Config): [string, string | undefined]; | ||
abstract run(): Promise<void>; | ||
} |
@@ -25,2 +25,10 @@ "use strict"; | ||
} | ||
static buildHelp(config) { | ||
let help = new deps_1.default.Help(config); | ||
return help.command(this); | ||
} | ||
static buildHelpLine(config) { | ||
let help = new deps_1.default.Help(config); | ||
return help.commandLine(this); | ||
} | ||
get ctor() { | ||
@@ -31,5 +39,5 @@ return this.constructor; | ||
const { argv, flags, args } = await deps_1.default.CLIFlags.parse({ | ||
args: this.ctor.args || [], | ||
argv: this.argv.slice(1), | ||
flags: this.ctor.flags || {}, | ||
argv: this.argv.slice(1), | ||
args: this.ctor.args || [], | ||
strict: !this.ctor.variableArgs, | ||
@@ -41,14 +49,2 @@ }); | ||
} | ||
/** | ||
* actual command run code goes here | ||
*/ | ||
async run() { } | ||
static buildHelp(config) { | ||
let help = new deps_1.default.Help(config); | ||
return help.command(this); | ||
} | ||
static buildHelpLine(config) { | ||
let help = new deps_1.default.Help(config); | ||
return help.commandLine(this); | ||
} | ||
} | ||
@@ -58,2 +54,3 @@ Command.aliases = []; | ||
Command.args = []; | ||
// tslint:disable-next-line | ||
Command._version = pjson.version; | ||
@@ -67,4 +64,4 @@ /** | ||
cmd, | ||
stderr: deps_1.default.cli.stderr.output, | ||
stdout: deps_1.default.cli.stdout.output, | ||
stderr: deps_1.default.cli.stderr.output, | ||
}; | ||
@@ -71,0 +68,0 @@ }; |
@@ -0,6 +1,6 @@ | ||
import { Chalk } from 'chalk'; | ||
import Config = require('cli-engine-config'); | ||
import CLIFlags = require('cli-flags'); | ||
import CLI = require('cli-ux'); | ||
import HTTP = require('http-call'); | ||
import CLIFlags = require('cli-flags'); | ||
import { Chalk } from 'chalk'; | ||
import help = require('./help'); | ||
@@ -7,0 +7,0 @@ export declare const deps: { |
import { Config } from 'cli-engine-config'; | ||
import { flags } from 'cli-flags'; | ||
export interface CompletionContext { | ||
export interface ICompletionContext { | ||
args?: { | ||
@@ -13,15 +13,15 @@ [name: string]: string; | ||
} | ||
export interface Completion { | ||
export interface ICompletion { | ||
skipCache?: boolean; | ||
cacheDuration?: number; | ||
cacheKey?: (ctx: CompletionContext) => Promise<string>; | ||
options: (ctx: CompletionContext) => Promise<string[]>; | ||
cacheKey?: (ctx: ICompletionContext) => Promise<string>; | ||
options: (ctx: ICompletionContext) => Promise<string[]>; | ||
} | ||
export interface IOptionFlag<T = string> extends flags.IOptionFlag<T> { | ||
completion?: Completion; | ||
completion?: ICompletion; | ||
} | ||
export declare type IFlag<T = string> = flags.IBooleanFlag | IOptionFlag<T>; | ||
export declare type Input = { | ||
export interface Input { | ||
[k: string]: IFlag<any>; | ||
}; | ||
} | ||
export declare type Definition<T = string> = (options?: Partial<IOptionFlag<T>>) => IOptionFlag<T>; | ||
@@ -28,0 +28,0 @@ export declare function option<T = string>(defaults?: Partial<IOptionFlag<T>>): Definition<T>; |
import { Config, ICommand } from 'cli-engine-config'; | ||
import { flags, args } from 'cli-flags'; | ||
import { args, flags } from 'cli-flags'; | ||
export declare class Help { | ||
@@ -9,4 +9,4 @@ config: Config; | ||
renderAliases(aliases: string[] | undefined): string; | ||
renderArgs(args: args.IArg<string>[]): string; | ||
renderFlags(flags: flags.IFlag<any>[]): string; | ||
renderArgs(args: Array<args.IArg<string>>): string; | ||
renderFlags(flags: Array<flags.IFlag<any>>): string; | ||
} |
{ | ||
"name": "cli-engine-command", | ||
"description": "base CLI command for cli-engine", | ||
"version": "11.0.3", | ||
"version": "11.0.4", | ||
"author": "Jeff Dickey @jdxcode", | ||
@@ -26,2 +26,4 @@ "bugs": "https://github.com/heroku/cli-engine-command/issues", | ||
"ts-node": "4.0.2", | ||
"tslint": "^5.8.0", | ||
"tslint-cli-engine": "^1.0.0", | ||
"typescript": "2.6.2" | ||
@@ -48,3 +50,3 @@ }, | ||
"clean": "del-cli lib", | ||
"posttest": "prettier -l 'src/**/*.ts'", | ||
"posttest": "tslint -p . && prettier -l 'src/**/*.ts'", | ||
"precommit": "lint-staged", | ||
@@ -51,0 +53,0 @@ "prepare": "tsc", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12232
15
330