diff --git a/types/command-line-usage/command-line-usage-tests.ts b/types/command-line-usage/command-line-usage-tests.ts new file mode 100644 index 0000000000..05dfadc7f3 --- /dev/null +++ b/types/command-line-usage/command-line-usage-tests.ts @@ -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); diff --git a/types/command-line-usage/index.d.ts b/types/command-line-usage/index.d.ts new file mode 100644 index 0000000000..ac4f1d7606 --- /dev/null +++ b/types/command-line-usage/index.d.ts @@ -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 +// 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; diff --git a/types/command-line-usage/tsconfig.json b/types/command-line-usage/tsconfig.json new file mode 100644 index 0000000000..9deee9ab63 --- /dev/null +++ b/types/command-line-usage/tsconfig.json @@ -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" + ] +} diff --git a/types/command-line-usage/tslint.json b/types/command-line-usage/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/command-line-usage/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }