How to use the yargs-parser.detailed function in yargs-parser

To help you get started, we’ve selected a few yargs-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github publiclab / Leaflet.DistortableImage / node_modules / yargs-unparser / node_modules / yargs / yargs.js View on Github external
self._parseArgs = function parseArgs (args, shortCircuit, _skipValidation, commandIndex) {
    let skipValidation = !!_skipValidation
    args = args || processArgs

    options.__ = y18n.__
    options.configuration = self.getParserConfiguration()

    // Deprecated
    let pkgConfig = pkgUp()['yargs']
    if (pkgConfig) {
      console.warn('Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.')
      options.configuration = Object.assign({}, pkgConfig, options.configuration)
    }

    const parsed = Parser.detailed(args, options)
    let argv = parsed.argv
    if (parseContext) argv = Object.assign({}, argv, parseContext)
    const aliases = parsed.aliases

    argv.$0 = self.$0
    self.parsed = parsed

    try {
      guessLocale() // guess locale lazily, so that it can be turned off in chain.

      // while building up the argv object, there
      // are two passes through the parser. If completion
      // is being performed short-circuit on the first pass.
      if (shortCircuit) {
        return argv
      }
github ranjithprabhuk / ng2-Dashboard / node_modules / yargs / yargs.js View on Github external
function parseArgs (args, shortCircuit) {
    options.__ = y18n.__
    options.configuration = pkgConf.sync('yargs', {
      defaults: {},
      cwd: requireMainFilename(require)
    })
    const parsed = Parser.detailed(args, options)
    const argv = parsed.argv
    var aliases = parsed.aliases

    argv.$0 = self.$0
    self.parsed = parsed

    guessLocale() // guess locale lazily, so that it can be turned off in chain.

    // while building up the argv object, there
    // are two passes through the parser. If completion
    // is being performed short-circuit on the first pass.
    if (shortCircuit) {
      return argv
    }

    // if there's a handler associated with a
github Andyliwr / FE-learning-load / task08 / lidikang / styles / node_modules / yargs / yargs.js View on Github external
function parseArgs (args, shortCircuit) {
    options.__ = y18n.__
    options.configuration = pkgUp(cwd)['yargs'] || {}
    const parsed = Parser.detailed(args, options)
    const argv = parsed.argv
    var aliases = parsed.aliases

    argv.$0 = self.$0
    self.parsed = parsed

    guessLocale() // guess locale lazily, so that it can be turned off in chain.

    // while building up the argv object, there
    // are two passes through the parser. If completion
    // is being performed short-circuit on the first pass.
    if (shortCircuit) {
      return argv
    }

    // if there's a handler associated with a
github depjs / dep / node_modules / yargs / lib / command.js View on Github external
const unparsed = []
    Object.keys(positionalMap).forEach((key) => {
      positionalMap[key].map((value) => {
        unparsed.push(`--${key}`)
        unparsed.push(value)
      })
    })

    // short-circuit parse.
    if (!unparsed.length) return

    const config = Object.assign({}, options.configuration, {
      'populate--': true
    })
    const parsed = Parser.detailed(unparsed, Object.assign({}, options, {
      configuration: config
    }))

    if (parsed.error) {
      yargs.getUsageInstance().fail(parsed.error.message, parsed.error)
    } else {
      // only copy over positional keys (don't overwrite
      // flag arguments that were already parsed).
      const positionalKeys = Object.keys(positionalMap)
      Object.keys(positionalMap).forEach((key) => {
        [].push.apply(positionalKeys, parsed.aliases[key])
      })

      Object.keys(parsed.argv).forEach((key) => {
        if (positionalKeys.indexOf(key) !== -1) {
          // any new aliases need to be placed in positionalMap, which
github graalvm / graaljs / deps / npm / node_modules / yargs / lib / command.js View on Github external
options.default = Object.assign(parseOptions.default, options.default)
    options.alias = Object.assign(parseOptions.alias, options.alias)
    options.array = options.array.concat(parseOptions.array)

    const unparsed = []
    Object.keys(positionalMap).forEach((key) => {
      positionalMap[key].map((value) => {
        unparsed.push(`--${key}`)
        unparsed.push(value)
      })
    })

    // short-circuit parse.
    if (!unparsed.length) return

    const parsed = Parser.detailed(unparsed, options)

    if (parsed.error) {
      yargs.getUsageInstance().fail(parsed.error.message, parsed.error)
    } else {
      // only copy over positional keys (don't overwrite
      // flag arguments that were already parsed).
      const positionalKeys = Object.keys(positionalMap)
      Object.keys(positionalMap).forEach((key) => {
        [].push.apply(positionalKeys, parsed.aliases[key])
      })

      Object.keys(parsed.argv).forEach((key) => {
        if (positionalKeys.indexOf(key) !== -1) {
          argv[key] = parsed.argv[key]
        }
      })
github albertnadal / ng2-daterange-picker / node_modules / yargs / yargs.js View on Github external
self._parseArgs = function (args, shortCircuit, _skipValidation) {
    var skipValidation = !!_skipValidation
    args = args || processArgs

    options.__ = y18n.__
    options.configuration = pkgUp()['yargs'] || {}
    const parsed = Parser.detailed(args, options)
    var argv = parsed.argv
    if (parseContext) argv = assign(argv, parseContext)
    var aliases = parsed.aliases

    argv.$0 = self.$0
    self.parsed = parsed

    try {
      guessLocale() // guess locale lazily, so that it can be turned off in chain.

      // while building up the argv object, there
      // are two passes through the parser. If completion
      // is being performed short-circuit on the first pass.
      if (shortCircuit) {
        return argv
      }
github fossasia / susper.com / node_modules / webpack / node_modules / yargs / yargs.js View on Github external
self._parseArgs = function (args, shortCircuit, _skipValidation, commandIndex) {
    var skipValidation = !!_skipValidation
    args = args || processArgs

    options.__ = y18n.__
    options.configuration = pkgUp()['yargs'] || {}
    const parsed = Parser.detailed(args, options)
    var argv = parsed.argv
    if (parseContext) argv = assign(argv, parseContext)
    var aliases = parsed.aliases

    argv.$0 = self.$0
    self.parsed = parsed

    try {
      guessLocale() // guess locale lazily, so that it can be turned off in chain.

      // while building up the argv object, there
      // are two passes through the parser. If completion
      // is being performed short-circuit on the first pass.
      if (shortCircuit) {
        return argv
      }
github M0nica / React-Ladies / node_modules / yargs / lib / command.js View on Github external
options.default = Object.assign(parseOptions.default, options.default)
    options.alias = Object.assign(parseOptions.alias, options.alias)
    options.array = options.array.concat(parseOptions.array)

    const unparsed = []
    Object.keys(positionalMap).forEach((key) => {
      positionalMap[key].map((value) => {
        unparsed.push(`--${key}`)
        unparsed.push(value)
      })
    })

    // short-circuit parse.
    if (!unparsed.length) return

    const parsed = Parser.detailed(unparsed, options)

    if (parsed.error) {
      yargs.getUsageInstance().fail(parsed.error.message, parsed.error)
    } else {
      // only copy over positional keys (don't overwrite
      // flag arguments that were already parsed).
      const positionalKeys = Object.keys(positionalMap)
      Object.keys(positionalMap).forEach((key) => {
        [].push.apply(positionalKeys, parsed.aliases[key])
      })

      Object.keys(parsed.argv).forEach((key) => {
        if (positionalKeys.indexOf(key) !== -1) {
          argv[key] = parsed.argv[key]
        }
      })
github tommy351 / kosko / packages / cli / src / cli / parse.ts View on Github external
export function parse(
  argv: string[],
  cmd: Pick, "options" | "args">,
  config: Partial = {}
): ParseResult {
  const detail = parser.detailed(argv, {
    configuration: config,
    ...getParserOptions(cmd.options || {})
  });

  const { options, errors: optErrors } = validateOptions(
    detail,
    cmd.options || {}
  );
  const { args, errors: argErrors } = validateArgs(detail, cmd.args || []);

  return {
    detail,
    options,
    args,
    errors: [...optErrors, ...argErrors]
  };

yargs-parser

the mighty option parser used by yargs

ISC
Latest version published 2 years ago

Package Health Score

77 / 100
Full package analysis