| 1 | // Main entrypoint for ESM web browser environments. Avoids using Node.js
|
|---|
| 2 | // specific libraries, such as "path".
|
|---|
| 3 | //
|
|---|
| 4 | // TODO: figure out reasonable web equivalents for "resolve", "normalize", etc.
|
|---|
| 5 | import { camelCase, decamelize, looksLikeNumber } from './build/lib/string-utils.js'
|
|---|
| 6 | import { YargsParser } from './build/lib/yargs-parser.js'
|
|---|
| 7 | const parser = new YargsParser({
|
|---|
| 8 | cwd: () => { return '' },
|
|---|
| 9 | format: (str, arg) => { return str.replace('%s', arg) },
|
|---|
| 10 | normalize: (str) => { return str },
|
|---|
| 11 | resolve: (str) => { return str },
|
|---|
| 12 | require: () => {
|
|---|
| 13 | throw Error('loading config from files not currently supported in browser')
|
|---|
| 14 | },
|
|---|
| 15 | env: () => {}
|
|---|
| 16 | })
|
|---|
| 17 |
|
|---|
| 18 | const yargsParser = function Parser (args, opts) {
|
|---|
| 19 | const result = parser.parse(args.slice(), opts)
|
|---|
| 20 | return result.argv
|
|---|
| 21 | }
|
|---|
| 22 | yargsParser.detailed = function (args, opts) {
|
|---|
| 23 | return parser.parse(args.slice(), opts)
|
|---|
| 24 | }
|
|---|
| 25 | yargsParser.camelCase = camelCase
|
|---|
| 26 | yargsParser.decamelize = decamelize
|
|---|
| 27 | yargsParser.looksLikeNumber = looksLikeNumber
|
|---|
| 28 |
|
|---|
| 29 | export default yargsParser
|
|---|