mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-07 10:40:13 +00:00
20
nopt/nopt-tests.ts
Normal file
20
nopt/nopt-tests.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Maintained by: jbondc <https://github.com/jbondc>
|
||||
*/
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="nopt.d.ts" />
|
||||
|
||||
import nopt = require("nopt");
|
||||
|
||||
nopt({"--foo" : String})
|
||||
|
||||
nopt({ "--foo": String }, { "-f": "--foo"})
|
||||
nopt({ "--foo": String }, { "-f": ["--foo", "-d"] })
|
||||
|
||||
nopt({ "--foo": String }, { "-f": ["--foo", "-d"] }, ["test me --foo arg"])
|
||||
var cmd = nopt({ "--foo": String }, { "-f": ["--foo", "-d"] }, ["test me --foo arg"], 2)
|
||||
|
||||
console.log(cmd.argv.cooked)
|
||||
console.log(cmd.argv.original)
|
||||
console.log(cmd.argv.remain)
|
||||
46
nopt/nopt.d.ts
vendored
Normal file
46
nopt/nopt.d.ts
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
// Type definitions for nopt 3.0.1
|
||||
// Project: https://github.com/npm/nopt
|
||||
// Definitions by: jbondc <https://github.com/jbondc>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "nopt" {
|
||||
|
||||
interface CommandData {
|
||||
[key: string]: string
|
||||
}
|
||||
|
||||
interface TypeDefs {
|
||||
[key: string]: TypeInfo
|
||||
}
|
||||
|
||||
interface TypeInfo {
|
||||
type: Object
|
||||
validate: (data: CommandData, k: string, val: string) => boolean
|
||||
}
|
||||
|
||||
module nopt {
|
||||
export function clean(data: CommandData, types: FlagTypeMap, typeDefs?: TypeDefs): string
|
||||
export var typeDefs: TypeDefs
|
||||
}
|
||||
|
||||
interface FlagTypeMap {
|
||||
[k: string]: Object
|
||||
}
|
||||
|
||||
interface ShortFlags {
|
||||
[k: string]: string[]|string
|
||||
}
|
||||
|
||||
function nopt(types: FlagTypeMap, shorthands?: ShortFlags, args?: string[], slice?: number): OptionsParsed
|
||||
|
||||
interface OptionsParsed {
|
||||
[k: string]: any
|
||||
argv: {
|
||||
remain: string[]
|
||||
cooked: string[]
|
||||
original: string[]
|
||||
}
|
||||
}
|
||||
|
||||
export = nopt
|
||||
}
|
||||
Reference in New Issue
Block a user