UNPKG

2.75 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/sade`
3
4# Summary
5This package contains type definitions for sade (https://github.com/lukeed/sade#readme).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sade.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sade/index.d.ts)
10````ts
11// Type definitions for sade 1.7
12// Project: https://github.com/lukeed/sade#readme
13// Definitions by: Epimodev <https://github.com/Epimodev>
14// Piotr Błażejewicz <https://github.com/peterblazejewicz>
15// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
16
17import * as mri from 'mri';
18
19/**
20 * Sade is a small but powerful tool for building command-line interface (CLI) applications for Node.js that are fast, responsive, and helpful!
21 * It enables default commands, git-like subcommands, option flags with aliases, default option values with type-casting,
22 * required-vs-optional argument handling, command validation, and automated help text generation!
23 */
24declare namespace sade {
25 type Handler = (...args: any[]) => any;
26
27 interface CommandOptions {
28 /**
29 * Optionally define one or more aliases for the current Command.
30 * When declared, the `opts.alias` value is passed directly to the [`prog.alias`](#progaliasnames) method.
31 */
32 alias?: string | string[] | undefined;
33 default?: boolean | undefined;
34 }
35
36 interface ParseOptions extends mri.Options {
37 lazy?: boolean | undefined;
38 }
39
40 interface LazyOutput {
41 name: string;
42 handler: Handler;
43 args: string[];
44 }
45
46 interface Sade {
47 /**
48 * Define one or more aliases for the current Command.
49 */
50 alias(...names: string[]): Sade;
51 command(str: string, desc?: string, opts?: Readonly<CommandOptions>): Sade;
52 describe(str: string | ReadonlyArray<string>): Sade;
53 option(str: string, desc: string, val?: string | number | boolean): Sade;
54 action(handler: Handler): Sade;
55 example(str: string): Sade;
56 version(str: string): Sade;
57 help(str: string): void;
58
59 parse(arr: string[], opts: { lazy: true } & ParseOptions): LazyOutput;
60 parse(arr: string[], opts?: ParseOptions): void;
61 }
62}
63
64declare function sade(str: string, isOne?: boolean): sade.Sade;
65
66export = sade;
67
68````
69
70### Additional Details
71 * Last updated: Tue, 06 Jul 2021 16:34:11 GMT
72 * Dependencies: [@types/mri](https://npmjs.com/package/@types/mri)
73 * Global values: none
74
75# Credits
76These definitions were written by [Epimodev](https://github.com/Epimodev), and [Piotr Błażejewicz](https://github.com/peterblazejewicz).
77
\No newline at end of file