clipanion
Advanced tools
Comparing version 3.2.0-rc.7 to 3.2.0-rc.8
@@ -54,5 +54,5 @@ /// <reference types="node" /> | ||
export declare type PartialContext<Context extends BaseContext> = UserContextKeys<Context> extends never ? Partial<Pick<Context, keyof BaseContext>> | undefined | void : Partial<Pick<Context, keyof BaseContext>> & UserContext<Context>; | ||
export declare type RunContext<Context extends BaseContext> = Partial<Pick<Context, keyof BaseContext>> & UserContext<Context>; | ||
export declare type RunCommand<Context extends BaseContext> = Array<CommandClass<Context>> | CommandClass<Context>; | ||
export declare type RunCommandNoContext<Context extends BaseContext> = UserContextKeys<Context> extends never ? RunCommand<Context> : never; | ||
export declare type RunContext<Context extends BaseContext = BaseContext> = Partial<Pick<Context, keyof BaseContext>> & UserContext<Context>; | ||
export declare type RunCommand<Context extends BaseContext = BaseContext> = Array<CommandClass<Context>> | CommandClass<Context>; | ||
export declare type RunCommandNoContext<Context extends BaseContext = BaseContext> = UserContextKeys<Context> extends never ? RunCommand<Context> : never; | ||
export declare type CliOptions = Readonly<{ | ||
@@ -59,0 +59,0 @@ /** |
@@ -41,2 +41,4 @@ 'use strict'; | ||
let resolvedContext; | ||
if (typeof process !== `undefined` && typeof process.argv !== `undefined`) | ||
resolvedArgv = process.argv.slice(2); | ||
switch (args.length) { | ||
@@ -72,10 +74,10 @@ case 1: | ||
} | ||
else if (args[1] && (args[1].prototype instanceof Command.Command) || Array.isArray(args[1])) { | ||
resolvedOptions = args[0]; | ||
resolvedCommandClasses = args[1]; | ||
else if (args[0] && (args[0].prototype instanceof Command.Command) || Array.isArray(args[0])) { | ||
resolvedCommandClasses = args[0]; | ||
resolvedArgv = args[1]; | ||
resolvedContext = args[2]; | ||
} | ||
else { | ||
resolvedCommandClasses = args[0]; | ||
resolvedArgv = args[1]; | ||
resolvedOptions = args[0]; | ||
resolvedCommandClasses = args[1]; | ||
resolvedContext = args[2]; | ||
@@ -94,2 +96,4 @@ } | ||
} | ||
if (typeof resolvedArgv === `undefined`) | ||
throw new Error(`The argv parameter must be provided when running Clipanion outside of a Node context`); | ||
return { | ||
@@ -96,0 +100,0 @@ resolvedOptions, |
@@ -14,3 +14,3 @@ { | ||
], | ||
"version": "3.2.0-rc.7", | ||
"version": "3.2.0-rc.8", | ||
"main": "lib/advanced/index", | ||
@@ -59,3 +59,3 @@ "license": "MIT", | ||
"postpack": "rm -rf lib", | ||
"test": "FORCE_COLOR=1 mocha --require ts-node/register --extension ts tests", | ||
"test": "FORCE_COLOR=1 mocha --require ts-node/register --extension ts tests/specs", | ||
"lint": "eslint --max-warnings 0 .", | ||
@@ -62,0 +62,0 @@ "demo": "node --require ts-node/register sources/demos/advanced.ts" |
Sorry, the diff of this file is not supported yet
217417
5087