Added types for command-line-usage package

This commit is contained in:
Andrija Dvorski
2018-03-28 15:00:03 +02:00
parent b27c13d93a
commit 19341e612b
4 changed files with 96 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import * as commandLineUsage from "command-line-usage";
const sections = [
{
header: 'A typical app',
content: 'Generates something {italic very} important.'
},
{
header: 'Options',
optionList: [
{
name: 'input',
typeLabel: '{underline file}',
description: 'The input to process.'
},
{
name: 'help',
description: 'Print this usage guide.'
}
]
}
];
const usage = commandLineUsage(sections);

48
types/command-line-usage/index.d.ts vendored Normal file
View File

@@ -0,0 +1,48 @@
// Type definitions for command-line-usage 5.0
// Project: https://github.com/75lb/command-line-usage#readme
// Definitions by: Andrija Dvorski <https://github.com/Dvorsky>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
declare namespace commandLineUsage {
interface Section {
list: string[];
add(content: object): void;
emptyLine(): void;
header(text: string): void;
toString(): string;
}
interface SectionData {
optionList?: OptionListData[];
hide?: string[];
group?: string[];
header?: string;
reverseNameOrder?: boolean;
tableOptions?: any;
}
interface OptionListData extends SectionData {
name: string;
typeLabel?: string;
description?: string;
}
interface ContentSectionData extends SectionData {
content: string;
raw?: boolean;
}
type CommandLineUsageInput =
SectionData
| SectionData[]
| OptionListData
| OptionListData[]
| ContentSectionData
| ContentSectionData[];
}
declare function commandLineUsage(sections: commandLineUsage.CommandLineUsageInput): string | undefined | commandLineUsage.Section;
export = commandLineUsage;

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"command-line-usage-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }