diff --git a/types/sade/index.d.ts b/types/sade/index.d.ts new file mode 100644 index 0000000000..b911a04355 --- /dev/null +++ b/types/sade/index.d.ts @@ -0,0 +1,33 @@ +// Type definitions for sade 1.6 +// Project: https://github.com/lukeed/sade#readme +// Definitions by: Epimodev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as mri from 'mri'; + +type Handler = (...args: any[]) => void; + +declare namespace sade { + interface CommandOptions { + default?: boolean; + } + + interface ParseOptions extends mri.Options { + lazy?: boolean; + } + + interface Sade { + command(str: string, desc?: string, opts?: Readonly): Sade; + describe(str: string | ReadonlyArray): Sade; + option(str: string, desc: string, val?: string | number): Sade; + action(handler: Handler): Sade; + example(str: string): Sade; + version(str: string): Sade; + parse(arr: string[], opts?: Readonly): { args: string[]; name: string; handler: Handler } | void; + help(str: string): void; + } +} + +declare function sade(str: string, isOne?: boolean): sade.Sade; + +export = sade; diff --git a/types/sade/sade-tests.ts b/types/sade/sade-tests.ts new file mode 100644 index 0000000000..73feba57da --- /dev/null +++ b/types/sade/sade-tests.ts @@ -0,0 +1,20 @@ +import sade = require('sade'); + +const prog = sade('my-cli'); + +const argv = ['sirv', 'build']; + +prog.version('1.0.5') + .option('--global, -g', 'An example global flag') + .option('-c, --config', 'Provide path to custom config', 'foo.config.js'); + +prog.command('build ') + .describe('Build the source directory. Expects an `index.js` entry file.') + .option('-o, --output', 'Change the name of the output file', 'bundle.js') + .example('build src build --global --config my-conf.js') + .example('build app public -o main.js') + .action((src: any, dest: any, opts: any) => {}); + +prog.help('build'); + +prog.parse(argv); diff --git a/types/sade/tsconfig.json b/types/sade/tsconfig.json new file mode 100644 index 0000000000..abfdf6447f --- /dev/null +++ b/types/sade/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "sade-tests.ts" + ] +} diff --git a/types/sade/tslint.json b/types/sade/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/sade/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }