1 | // Type definitions for command-line-usage 5.0
|
2 | // Project: https://github.com/75lb/command-line-usage#readme
|
3 | // Definitions by: matrumz <https://github.com/matrumz>
|
4 | // Andrija Dvorski <https://github.com/Dvorsky>
|
5 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
6 | // TypeScript Version: 2.2
|
7 |
|
8 | /**
|
9 | * Generates a usage guide suitable for a command-line app.
|
10 | * @param sections One or more Section objects
|
11 | * @alias module:command-line-usage
|
12 | */
|
13 | declare function commandLineUsage(sections: commandLineUsage.Section | commandLineUsage.Section[]): string;
|
14 | export = commandLineUsage;
|
15 |
|
16 | declare namespace commandLineUsage {
|
17 | /** Section object. */
|
18 | type Section = Content | OptionList;
|
19 |
|
20 | /** A Content section comprises a header and one or more lines of content. */
|
21 | interface Content {
|
22 | /** The section header, always bold and underlined. */
|
23 | header?: string | undefined;
|
24 | /**
|
25 | * Overloaded property, accepting data in one of four formats.
|
26 | * 1. A single string (one line of text).
|
27 | * 2. An array of strings (multiple lines of text).
|
28 | * 3. An array of objects (recordset-style data). In this case, the data will be rendered in table format. The property names of each object are not important, so long as they are
|
29 | * consistent throughout the array.
|
30 | * 4. An object with two properties - data and options. In this case, the data and options will be passed directly to the underlying table layout module for rendering.
|
31 | */
|
32 | content?: string | string[] | any[] | { data: any; options: any } | undefined;
|
33 | /** Set to true to avoid indentation and wrapping. Useful for banners. */
|
34 | raw?: boolean | undefined;
|
35 | }
|
36 |
|
37 | /** Describes a command-line option. Additionally, if generating a usage guide with command-line-usage you could optionally add description and typeLabel properties to each definition. */
|
38 | interface OptionDefinition {
|
39 | name: string;
|
40 | /**
|
41 | * The type value is a setter function (you receive the output from this), enabling you to be specific about the type and value received.
|
42 | *
|
43 | * The most common values used are String (the default), Number and Boolean but you can use a custom function.
|
44 | */
|
45 | type?: any;
|
46 | /** getopt-style short option names. Can be any single character (unicode included) except a digit or hyphen. */
|
47 | alias?: string | undefined;
|
48 | /** Set this flag if the option takes a list of values. You will receive an array of values, each passed through the type function (if specified). */
|
49 | multiple?: boolean | undefined;
|
50 | /** Identical to multiple but with greedy parsing disabled. */
|
51 | lazyMultiple?: boolean | undefined;
|
52 | /** Any values unaccounted for by an option definition will be set on the defaultOption. This flag is typically set on the most commonly-used option to make for more concise usage. */
|
53 | defaultOption?: boolean | undefined;
|
54 | /** An initial value for the option. */
|
55 | defaultValue?: any;
|
56 | /**
|
57 | * When your app has a large amount of options it makes sense to organise them in groups.
|
58 | *
|
59 | * There are two automatic groups: _all (contains all options) and _none (contains options without a group specified in their definition).
|
60 | */
|
61 | group?: string | string[] | undefined;
|
62 | /** A string describing the option. */
|
63 | description?: string | undefined;
|
64 | /** A string to replace the default type string (e.g. <string>). It's often more useful to set a more descriptive type label, like <ms>, <files>, <command>, etc.. */
|
65 | typeLabel?: string | undefined;
|
66 | }
|
67 |
|
68 | /** A OptionList section adds a table displaying details of the available options. */
|
69 | interface OptionList {
|
70 | header?: string | undefined;
|
71 | /** An array of option definition objects. */
|
72 | optionList?: OptionDefinition[] | undefined;
|
73 | /** If specified, only options from this particular group will be printed. */
|
74 | group?: string | string[] | undefined;
|
75 | /** The names of one of more option definitions to hide from the option list. */
|
76 | hide?: string | string[] | undefined;
|
77 | /** If true, the option alias will be displayed after the name, i.e. --verbose, -v instead of -v, --verbose). */
|
78 | reverseNameOrder?: boolean | undefined;
|
79 | /** An options object suitable for passing into table-layout. */
|
80 | tableOptions?: any;
|
81 | }
|
82 | }
|