diff --git a/argv/argv-tests.ts b/argv/argv-tests.ts new file mode 100644 index 0000000000..6d73c53ec7 --- /dev/null +++ b/argv/argv-tests.ts @@ -0,0 +1,15 @@ +/// +import argv = require('argv'); +argv.version( 'v1.0' ); +argv.info( 'Special script info' ); +argv.clear() +.option({ + name: 'option', + short: 'o', + type: 'string', + description: 'Defines an option for your script', + example: "'script --opiton=value' or 'script -o value'" +}) +.run([ '--option=123', '-o', '123' ]); +argv.run(); +argv.help(); diff --git a/argv/argv.d.ts b/argv/argv.d.ts new file mode 100644 index 0000000000..182ffde861 --- /dev/null +++ b/argv/argv.d.ts @@ -0,0 +1,59 @@ +// Type definitions for argv +// Project: https://www.npmjs.com/package/argv +// Definitions by: Hookclaw +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +declare module "argv" { + // argv module + type args = { + targets:string[], + options:{[key:string]:any} + }; + + type helpOption = { + name: string, + type: string, + short?: string, + description?: string, + example?: string + }; + + type module = { + mod: string, + description: string, + options: {[key:string]:helpOption} + }; + + type typeFunction = (value:any, ...arglist:any[]) => any; + + type argv = { + + // Runs the arguments parser + run: ( argv?:string[] ) => args, + + // Adding options to definitions list + option: ( mod:helpOption|helpOption[] ) => argv, + + // Creating module + mod: ( object:module|module[] ) => argv, + + // Creates custom type function + type: ( name:string|{[key:string]:typeFunction}, callback?:typeFunction ) => any, + + // Setting version number, and auto setting version option + version: ( v:string ) => argv, + + // Description setup + info: ( mod:string, description?:module ) => argv, + + // Cleans out current options + clear: () => argv, + + // Prints out the help doc + help: ( mod?:string ) => argv + + }; + + var argv:argv; + + export = argv; +}