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.
5import { camelCase, decamelize, looksLikeNumber } from './build/lib/string-utils.js'
6import { YargsParser } from './build/lib/yargs-parser.js'
7const 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
18const yargsParser = function Parser (args, opts) {
19  const result = parser.parse(args.slice(), opts)
20  return result.argv
21}
22yargsParser.detailed = function (args, opts) {
23  return parser.parse(args.slice(), opts)
24}
25yargsParser.camelCase = camelCase
26yargsParser.decamelize = decamelize
27yargsParser.looksLikeNumber = looksLikeNumber
28
29export default yargsParser
30