mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-06 06:19:58 +08:00
Merge pull request #24097 from bitjson/meow
Meow: allow immutable params, change Result.pkg to type `any`
This commit is contained in:
19
types/meow/index.d.ts
vendored
19
types/meow/index.d.ts
vendored
@@ -1,20 +1,27 @@
|
||||
// Type definitions for meow 4.x
|
||||
// Project: https://github.com/sindresorhus/meow
|
||||
// Definitions by: KnisterPeter <https://github.com/KnisterPeter>, Lindsey Smith <https://github.com/praxxis>
|
||||
// Definitions by: KnisterPeter <https://github.com/KnisterPeter>
|
||||
// Lindsey Smith <https://github.com/praxxis>
|
||||
// Jason Dreyzehner <https://github.com/bitjson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import * as buildOptions from "minimist-options";
|
||||
import * as buildOptions from 'minimist-options';
|
||||
|
||||
declare function meow(helpMessage: string | string[], options: meow.Options): meow.Result;
|
||||
declare function meow(options: string | string[] | meow.Options): meow.Result;
|
||||
declare function meow(
|
||||
helpMessage: string | ReadonlyArray<string>,
|
||||
options: meow.Options
|
||||
): meow.Result;
|
||||
declare function meow(
|
||||
options: string | ReadonlyArray<string> | meow.Options
|
||||
): meow.Result;
|
||||
declare namespace meow {
|
||||
interface Options {
|
||||
description?: string | boolean;
|
||||
help?: string | boolean;
|
||||
version?: string | boolean;
|
||||
pkg?: any;
|
||||
argv?: string[];
|
||||
argv?: ReadonlyArray<string>;
|
||||
inferType?: boolean;
|
||||
flags?: buildOptions.Options;
|
||||
autoHelp?: boolean;
|
||||
@@ -24,7 +31,7 @@ declare namespace meow {
|
||||
interface Result {
|
||||
input: string[];
|
||||
flags: { [name: string]: any };
|
||||
pkg: object;
|
||||
pkg: any;
|
||||
help: string;
|
||||
showHelp(code?: number): void;
|
||||
showVersion(): void;
|
||||
|
||||
@@ -1,28 +1,31 @@
|
||||
import meow = require('meow');
|
||||
|
||||
const cli = meow("Help text",
|
||||
{
|
||||
flags: {
|
||||
unicorn: {
|
||||
type: 'boolean',
|
||||
alias: 'u'
|
||||
},
|
||||
fooBar: {
|
||||
type: 'string',
|
||||
default: 'foo'
|
||||
}
|
||||
const cli = meow('Help text', {
|
||||
flags: {
|
||||
unicorn: {
|
||||
type: 'boolean',
|
||||
alias: 'u'
|
||||
},
|
||||
fooBar: {
|
||||
type: 'string',
|
||||
default: 'foo'
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
const cli2 = meow("Help text");
|
||||
const input: string = cli.input[0];
|
||||
const version: string = cli.pkg.version;
|
||||
|
||||
const cli2 = meow('Help text');
|
||||
|
||||
const args: ReadonlyArray<string> = ['foo', 'bar'];
|
||||
|
||||
const cli3 = meow({
|
||||
description: "version string",
|
||||
help: "help string",
|
||||
version: "1.0.0",
|
||||
description: 'version string',
|
||||
help: 'help string',
|
||||
version: '1.0.0',
|
||||
pkg: {},
|
||||
argv: ['foo', 'bar'],
|
||||
argv: args,
|
||||
inferType: true,
|
||||
autoHelp: true,
|
||||
autoVersion: true,
|
||||
|
||||
Reference in New Issue
Block a user