Comparing version 0.14.1 to 0.15.0
@@ -13,2 +13,4 @@ import {Readable, Writable} from 'stream'; | ||
type ExitCode = number | void; | ||
export interface Command { | ||
@@ -27,3 +29,3 @@ validate(validator: Validator): Command; | ||
action(action: (env: Environment) => Promise<Number | undefined> | Number | undefined): Command; | ||
action(action: (env: Environment) => ExitCode | Promise<ExitCode>): Command; | ||
} | ||
@@ -49,6 +51,6 @@ | ||
run(argv0: string, argv: Array<string>, opts?: Partial<Environment>): Promise<Number | undefined> | Number | undefined; | ||
run(argv0: string, argv: Array<string>, opts?: Partial<Environment>): ExitCode | Promise<ExitCode>; | ||
runExit(argv0: string, argv: Array<string>, opts?: Partial<Environment>): Promise<void>; | ||
} | ||
export default Clipanion; | ||
export const clipanion: Clipanion; |
{ | ||
"name": "clipanion", | ||
"version": "0.14.1", | ||
"version": "0.15.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "./sources/core/index.js", |
@@ -568,3 +568,3 @@ const chalk = require('chalk'); | ||
if (!current.rest.match(/^[a-z0-9]*$/)) | ||
if (!current.rest.match(/^[a-zA-Z0-9]*$/)) | ||
throw new UsageError(`Malformed option list "${current.literal}"`); | ||
@@ -690,3 +690,3 @@ | ||
selectedCommand = nextSelectedCommand; | ||
commandPath = commandBuffer; | ||
commandPath = commandBuffer.slice(); | ||
} | ||
@@ -719,6 +719,6 @@ | ||
if (commandPath.length > 0) | ||
if (argv.length === 0 || (argv.length === 1 && (argv[0] === `-h` || argv[0] === `--help`))) | ||
this.usage(argv0, { stream: stdout }); | ||
else | ||
this.usage(argv0, { command: selectedCommand, stream: stdout }); | ||
else | ||
this.usage(argv0, { stream: stdout }); | ||
@@ -725,0 +725,0 @@ return 0; |
@@ -105,2 +105,11 @@ const { expect } = require('chai'); | ||
it(`should not eat positional arguments when discarding an obsolete candidate`, async () => { | ||
let [ command, env ] = await clipanion.run(null, [ `b`, `not-foobar` ]); | ||
expect(command).to.equal(`command-b`); | ||
expect(env.args).to.deep.equal([ `not-foobar` ]); | ||
}); | ||
it(`should not select the default command if another one seems to be a better match`, async () => { | ||
@@ -175,2 +184,11 @@ | ||
it(`should support passing multiple boolean arguments in one shortname`, async () => { | ||
let [ command, env ] = await clipanion.run(null, [ `command-a`, `-FX` ]); | ||
expect(env.foo).to.equal(false); | ||
expect(env.withFoobar).to.equal(false); | ||
}); | ||
it(`should assign "0" as initial value for short options expecting to be repeated`, async () => { | ||
@@ -241,2 +259,10 @@ | ||
it(`should assign a string when using an argument-aware option long name (with a =)`, async () => { | ||
let [ command, env ] = await clipanion.run(null, [ `command-a`, `--arg=.js` ]); | ||
expect(env.arg).to.equal(`.js`); | ||
}); | ||
it(`should assign a string when using an argument-aware option short name (external argument)`, async () => { | ||
@@ -243,0 +269,0 @@ |
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
138126
14
2993