UNPKG

957 BTypeScriptView Raw
1// Type definitions for nopt 3.0.1
2// Project: https://github.com/npm/nopt
3// Definitions by: jbondc <https://github.com/jbondc>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6
7
8interface CommandData {
9 [key: string]: string
10}
11
12interface TypeDefs {
13 [key: string]: TypeInfo
14}
15
16interface TypeInfo {
17 type: Object
18 validate: (data: CommandData, k: string, val: string) => boolean
19}
20
21declare namespace nopt {
22 export function clean(data: CommandData, types: FlagTypeMap, typeDefs?: TypeDefs): string
23 export var typeDefs: TypeDefs
24}
25
26interface FlagTypeMap {
27 [k: string]: Object
28}
29
30interface ShortFlags {
31 [k: string]: string[] | string
32}
33
34declare function nopt(types: FlagTypeMap, shorthands?: ShortFlags, args?: string[], slice?: number): OptionsParsed
35
36interface OptionsParsed {
37 [k: string]: any
38 argv: {
39 remain: string[]
40 cooked: string[]
41 original: string[]
42 }
43}
44
45export = nopt