yargs-parser
Advanced tools
Comparing version 19.0.0-beta.2 to 19.0.0-beta.3
@@ -5,2 +5,3 @@ // Main entrypoint for ESM web browser environments. Avoids using Node.js | ||
// TODO: figure out reasonable web equivalents for "resolve", "normalize", etc. | ||
import { camelCase, decamelize } from './build/lib/string-utils.js' | ||
import { YargsParser } from './build/lib/yargs-parser.js' | ||
@@ -22,7 +23,8 @@ const parser = new YargsParser({ | ||
} | ||
yargsParser.detailed = function (args, opts) { | ||
return parser.parse(args.slice(), opts) | ||
} | ||
yargsParser.camelCase = camelCase | ||
yargsParser.decamelize = decamelize | ||
export default yargsParser |
@@ -0,12 +1,7 @@ | ||
/** | ||
* An object whose all properties have the same type, where each key is a string. | ||
*/ | ||
interface Dictionary<T = any> { | ||
[key: string]: T; | ||
} /** | ||
* Returns the keys of T. | ||
*/ | ||
/** | ||
* Returns the keys of T. | ||
*/ | ||
/** | ||
* Returns the keys of T. | ||
*/ | ||
} | ||
type ArgsInput = string | any[]; | ||
@@ -127,4 +122,6 @@ type ArgsOutput = (string | number)[]; | ||
detailed(args: ArgsInput, opts?: Partial<Options>): DetailedArguments; | ||
camelCase(str: string): string; | ||
decamelize(str: string, joinString?: string): string; | ||
} | ||
declare const yargsParser: Parser; | ||
export = yargsParser; |
@@ -6,2 +6,3 @@ // Main entrypoint for libraries using yargs-parser in Node.js | ||
import { normalize, resolve } from 'path'; | ||
import { camelCase, decamelize } from './string-utils.js'; | ||
import { YargsParser } from './yargs-parser.js'; | ||
@@ -49,2 +50,4 @@ // See https://github.com/yargs/yargs-parser#supported-nodejs-versions for our | ||
}; | ||
yargsParser.camelCase = camelCase; | ||
yargsParser.decamelize = decamelize; | ||
export default yargsParser; |
@@ -126,2 +126,4 @@ import type { Dictionary, KeyOf, ValueOf } from './common-types.js'; | ||
detailed(args: ArgsInput, opts?: Partial<Options>): DetailedArguments; | ||
camelCase(str: string): string; | ||
decamelize(str: string, joinString?: string): string; | ||
} | ||
@@ -128,0 +130,0 @@ export declare type StringFlag = Dictionary<string[]>; |
@@ -285,3 +285,4 @@ import { tokenizeArgString } from './tokenize-arg-string.js'; | ||
if (/[A-Za-z]/.test(letters[j]) && | ||
/^-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) { | ||
/^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) && | ||
checkAllAliases(next, flags.bools) === false) { | ||
setArg(letters[j], next); | ||
@@ -288,0 +289,0 @@ broken = true; |
{ | ||
"name": "yargs-parser", | ||
"version": "19.0.0-beta.2", | ||
"version": "19.0.0-beta.3", | ||
"description": "the mighty option parser used by yargs", | ||
@@ -5,0 +5,0 @@ "main": "build/index.cjs", |
@@ -21,3 +21,3 @@ # yargs-parser | ||
```js | ||
var argv = require('yargs-parser')(process.argv.slice(2)) | ||
const argv = require('yargs-parser')(process.argv.slice(2)) | ||
console.log(argv) | ||
@@ -34,3 +34,3 @@ ``` | ||
```js | ||
var argv = require('yargs-parser')('--foo=99 --bar=33') | ||
const argv = require('yargs-parser')('--foo=99 --bar=33') | ||
console.log(argv) | ||
@@ -46,3 +46,3 @@ ``` | ||
```js | ||
var parse = require('yargs-parser') | ||
const parse = require('yargs-parser') | ||
parse(['-f', 11, '--zoom', 55].join(' ')) // <-- array to string | ||
@@ -57,3 +57,3 @@ parse(['-f', 11, '--zoom', 55].map(String)) // <-- array of strings | ||
```typescript | ||
import parser from "https://github.com/yargs/yargs-parser/raw/deno/deno.ts"; | ||
import parser from "https://deno.land/x/yargs_parser/deno.ts"; | ||
@@ -68,7 +68,34 @@ const argv = parser('--foo=99 --bar=9987930', { | ||
As of `v19` `yargs-parser` supports ESM (_both in Node.js and in the browser_): | ||
**Node.js:** | ||
```js | ||
import parser from 'yargs-parser' | ||
const argv = parser('--foo=99 --bar=9987930', { | ||
string: ['bar'] | ||
}) | ||
console.log(argv) | ||
``` | ||
**Browsers:** | ||
```html | ||
<!doctype html> | ||
<body> | ||
<script type="module"> | ||
import parser from "https://unpkg.com/yargs-parser@19.0.0/browser.js"; | ||
const argv = parser('--foo=99 --bar=9987930', { | ||
string: ['bar'] | ||
}) | ||
console.log(argv) | ||
</script> | ||
</body> | ||
``` | ||
## API | ||
### require('yargs-parser')(args, opts={}) | ||
### parser(args, opts={}) | ||
@@ -75,0 +102,0 @@ Parses command line arguments returning a simple mapping of keys and values. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
134970
2638
500
0