Merge pull request #24589 from Dvorsky/feature/command-line-usage-types

Type definitions for command-line-usage 5.0
This commit is contained in:
Nathan Shively-Sanders
2018-03-29 05:54:18 -07:00
committed by GitHub
4 changed files with 96 additions and 0 deletions
@@ -0,0 +1,24 @@
import commandLineUsage = require("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
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;
+23
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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }