diff --git a/types/string-argv/index.d.ts b/types/string-argv/index.d.ts new file mode 100644 index 0000000000..eeaad53c87 --- /dev/null +++ b/types/string-argv/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for string-argv 0.1 +// Project: https://github.com/mccormicka/string-argv +// Definitions by: Vladimir Tikhonov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = parseArgsStringToArgv; + +/** + * Parses a string into an argument array to mimic `process.argv`. + * @param value - Arguments that you would normally pass to the command line. + * @param [env] - Adds to the environment position in the argv array. + * If ommitted then there is no need to call argv.split(2) to remove the environment/file values. + * However if your cli.parse method expects a valid argv value then you should include this value. + * @param [file] - File that called the arguments. + * If omitted then there is no need to call argv.split(2) to remove the environment/file values. + * However if your cli.parse method expects a valid argv value then you should include this value. + */ +declare function parseArgsStringToArgv(value: string, env?: string, file?: string): string[]; diff --git a/types/string-argv/string-argv-tests.ts b/types/string-argv/string-argv-tests.ts new file mode 100644 index 0000000000..87458ab6eb --- /dev/null +++ b/types/string-argv/string-argv-tests.ts @@ -0,0 +1,5 @@ +import parseArgsStringToArgv = require("string-argv"); + +const commandOnly = parseArgsStringToArgv("-test"); // $ExpectType string[] +const commandAndEnv = parseArgsStringToArgv("-test", "node"); // $ExpectType string[] +const commandEnvAndFile = parseArgsStringToArgv("-test", "node", "testing.js"); // $ExpectType string[] diff --git a/types/string-argv/tsconfig.json b/types/string-argv/tsconfig.json new file mode 100644 index 0000000000..15815c763e --- /dev/null +++ b/types/string-argv/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", + "string-argv-tests.ts" + ] +} diff --git a/types/string-argv/tslint.json b/types/string-argv/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/string-argv/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }