Normalize
: Spreads multi flag arguments and breaks arguments usign = sign.

@example
-am: returns -a, -m.
--flag=value: returns --flag, value.

@param args arguments to be normalized.
353731
function normalizeArgs(args, exclude) {
    var result = [];
    args = splitArgs(args || []);
    exclude = splitArgs(exclude || []);
    args.slice(0).forEach(function (arg) {
        var val;
        if (arg && arg.indexOf && ~arg.indexOf('=')) {
            var kv = arg.split('=');
            arg = kv[0];
            val = kv[1];
        }
        if (/^-{1}[a-z]+/i.test(arg)) {
            var spread = arg.slice(1).split('').map(function (a) { return '-' + a; });
            if (val)
                spread.push(val);
            result = result.concat(spread);
        }
        else {
            result.push(arg);
            if (val)
                result.push(val);
        }
    });
    return filterArgs(result, exclude);
}
1287191
public void setArgs(String argString)
  {
    try {
      if (argString != null) {
        String []args = Pattern.compile("[\\s,]+").split(argString);

        _args = new ArrayList<String>();

        for (int i = 0; i < args.length; i++) {
          if (! args[i].equals(""))
            _args.add(args[i]);
        }
      }
    } catch (Exception e) {
      log.log(Level.WARNING, e.toString(), e);
    }
  }
590586
function normalizeArgs (args) {
  var path, schema, options, callback;
  args = Array.prototype.slice.call(args);

  if (typeof args[args.length - 1] === "function") {
    // The last parameter is a callback function
    callback = args.pop();
  }

  if (typeof args[0] === "string") {
    // The first parameter is the path
    path = args[0];
    if (typeof args[2] === "object") {
      // The second parameter is the schema, and the third parameter is the options
      schema = args[1];
      options = args[2];
    }
    else {
      // The second parameter is the options
      schema = undefined;
      options = args[1];
    }
  }
  else {
    // The first parameter is the schema
    path = "";
    schema = args[0];
    options = args[1];
  }

  if (!(options instanceof Options)) {
    options = new Options(options);
  }

  return {
    path: path,
    schema: schema,
    options: options,
    callback: callback
  };
}
701690
def _check_arguments(self):
        """"""
        if self.argument_checked:
            return

        assert(self.symbol is not None)
        self.argument_checked = True

        # check if symbol contain duplicated names.
        _check_arguments(self.symbol)
        # rematch parameters to delete useless ones
        if self.allow_extra_params:
            if self.arg_params:
                arg_names = set(self.symbol.list_arguments())
                self.arg_params = {k : v for k, v in self.arg_params.items()
                                   if k in arg_names}
            if self.aux_params:
                aux_names = set(self.symbol.list_auxiliary_states())
                self.aux_params = {k : v for k, v in self.aux_params.items()
                                   if k in aux_names}
1067961
private void parse(String[] args) {
        for (int i=0; i<args.length; i++) {
            if (opt_with_value.containsKey(args[i])) {
                String key = opt_with_value.get(args[i]);
                values.put(key, args[i+1]);
                i++;
            } else if (args[i].startsWith("-")) {
                opt_without_value.add(args[i]);
            } else {
                arglist.add(args[i]);
            }
        }
    }
439560
private List<String> removeSeLionArgumentsAndValues(List<String> args) {
        // assume all of the ProcessLauncherConfiguration and LauncherConfiguration arguments should not be forwarded
        Set<Field> fields = new HashSet<>();
        fields.addAll(Arrays.asList(ProcessLauncherConfiguration.class.getDeclaredFields()));
        fields.addAll(Arrays.asList(LauncherConfiguration.class.getDeclaredFields()));

        for (Field field : fields) {
            // we need jcommander parameter fields only
            Parameter parameter = field.getAnnotation(Parameter.class);
            if (parameter == null) {
                continue;
            }

            // get the "arity" (how many values it can have on the command line) of the parameter/argument.
            // for example "-foo bar bar2"  --> argument = -foo --> arity = 2 --> values = {bar, bar2}
            final Class<?> fieldType = field.getType();
            final int arity = (parameter.arity() != -1) ? parameter.arity() :
                (fieldType.equals(Integer.class) || fieldType.equals(Long.class) || fieldType.equals(String.class) ||
                    fieldType.equals(int.class) || fieldType.equals(long.class)) ? 1 : 0;

            if (arity > 0) {
                for (String arg : args) {
                    // when the arg we are processing is one of the @Parameter names
                    if (Arrays.asList(parameter.names()).contains(arg)) {
                        // replace each value with ""
                        for (int x = 1; x <= arity; x += 1 ) {
                            args.set(args.indexOf(arg) + x, "");
                        }
                        // replace the argument with ""
                        args.set(args.indexOf(arg), "");
                    }
                }
                // remove all ""
                args.removeAll(Arrays.asList(""));
            } else {
                // the "arity" of the argument 0. there are no values to worry about.
                // remove all instances of the argument (and/or one of its names) from args
                args.removeAll(Arrays.asList(parameter.names()));
            }
        }

        return args;
    }
779071
private Object [] normalizeMessageArgs(Object [] args) {
    Object [] result = args;
    if(args != null && args.length > 0) {
      result = new Object[args.length];
      for(int i = 0; i < args.length; i++) {
        if(args[i] == null || args[i] instanceof CharSequence || args[i] instanceof Number) {
          result[i] = args[i];
        } else {
          result[i] = args[i].toString();
        }
      }
    }
    return result;
  }
893466
protected function normalizeArgs(array $args)
    {
        $error = $this->app->make('helper/validation/error');
        $normalized = [];
        $normalized['territoryRequestLevel'] = null;
        if (isset($args['territoryRequestLevel']) && (is_int($args['territoryRequestLevel']) || (is_string($args['territoryRequestLevel']) && is_numeric($args['territoryRequestLevel'])))) {
            $i = (int) $args['territoryRequestLevel'];
            switch ($i) {
                case self::TERRITORYREQUESTLEVEL_NEVER:
                case self::TERRITORYREQUESTLEVEL_OPTIONAL:
                case self::TERRITORYREQUESTLEVEL_NOTSOOPTIONAL:
                case self::TERRITORYREQUESTLEVEL_ALWAYS:
                    $normalized['territoryRequestLevel'] = $i;
                    break;
            }
        }
        if ($normalized['territoryRequestLevel'] === null) {
            $error->add(t('Please specify if and how the territory should be required'));
        }

        return $error->has() ? $error : $normalized;
    }
812297
function(args) {
  var argsMap = {};
  var mainPos = 1;

  while (args[mainPos].indexOf('--') > 0) {
    mainPos++;
  }
  argsMap.main = args[mainPos];

  for (var i = (mainPos + 1); i < args.length; i++) {
    var arg = args[i];
    var sep = arg.indexOf('=');
    var key = arg.slice(0, sep);
    var value = arg.slice(sep + 1);
    if (!isNaN(Number(value)) && (value.indexOf('.') < 0)) {
      value = Number(value);
    }
    argsMap[key] = value;
  }

  return argsMap;
}
58847
protected function normalizeArgs(array $args)
    {
        $error = $this->app->make('helper/validation/error');
        $normalized = [
            'askNewTeamCID' => null,
            'askNewTeamLink' => '',
        ];

        switch (isset($args['askNewTeamLinkType']) ? $args['askNewTeamLinkType'] : '') {
            case 'cid':
                if (isset($args['askNewTeamCID']) && ((is_string($args['askNewTeamCID']) && is_numeric($args['askNewTeamCID'])) || is_int($args['askNewTeamCID']))) {
                    $i = (int) $args['askNewTeamCID'];
                    if ($i > 0) {
                        $normalized['askNewTeamCID'] = $i;
                    }
                }
                break;
            case 'link':
                if (isset($args['askNewTeamLink']) && is_string($args['askNewTeamLink'])) {
                    $normalized['askNewTeamLink'] = trim($args['askNewTeamLink']);
                }
                break;
            }

        return $error->has() ? $error : $normalized;
    }
311292
function parse(args, exclude) {
    var normalized = normalizeArgs(args || _args, exclude);
    var clone = normalized.slice(0);
    clone.forEach(function (arg, i) {
        var next = clone[i + 1];
        var isFlag = _flagExp.test(arg);
        var isFlagNext = _flagExp.test(next || '');
        var isNoFlag = _noFlagExp.test(arg);
        if (isFlag) {
            var key = isNoFlag ? arg.replace(_noFlagExp, '') : arg.replace(_flagExp, '');
            key = key.split('.').map(function (k) { return chek_1.camelcase(k); }).join('.'); // handle dot keys.
            var curVal = chek_1.get(_flags, key);
            var exists = chek_1.isValue(curVal);
            if (exists)
                curVal = chek_1.toArray(curVal, []);
            if (!isFlagNext && next) {
                if (isNoFlag)
                    logger_1.log.error("Oops cannot set flag value using inverse (--no-xxx) flag " + arg + ".");
                var val = castToType(next);
                if (exists) {
                    curVal.push(val);
                    val = curVal;
                }
                chek_1.set(_flags, key, val);
                clone.splice(i + 1, 1);
            }
            else {
                chek_1.set(_flags, key, isNoFlag ? false : true);
            }
        }
        else {
            _commands.push(castToType(arg));
        }
    });
    if (_commands)
        _command = _commands.shift();
    return {
        command: _command,
        commands: _commands,
        cmd: _command,
        cmds: _commands,
        flags: _flags,
        source: _args,
        normalized: normalized
    };
}
34562
public void setArgs(final Serializable... args) {
		this.args = args == null || args.length == 0 ? null : args;
	}
719750
def normalize_args(f, *args, **kwargs):
    
    callargs = inspect.getcallargs(f, *args, **kwargs)
    original_callargs = callargs.copy()
    try:
        argspec = inspect.getargspec(f)
    except ValueError:
        argspec = inspect.getfullargspec(f)
    else:
        argspec = fullargspec_from_argspec(argspec)

    if hasattr(argspec, 'varkw'):
        if argspec.varkw:
            kwargs = callargs.pop(argspec.varkw, {})
            callargs.update(kwargs)

    if argspec.varargs:
        varargs = callargs.pop(argspec.varargs, ())
    else:
        varargs = ()

    # now callargs is all keywords

    return NormalizedArgs(varargs=varargs,
                          normargs=callargs,
                          callargs=original_callargs)
343383
private static void validateArguments(String[] args) {
    if (ArrayUtils.isEmpty(args)) {
      System.err.printf("$ java -server ... %s <port>%n", EchoServer.class.getName());
      System.exit(1);
    }
  }
774655
private void format(Object[] arguments, Map<String, Object> argsMap,
                        AppendableWrapper dest, FieldPosition fp) {
        if (arguments != null && msgPattern.hasNamedArguments()) {
            throw new IllegalArgumentException(
                "This method is not available in MessageFormat objects " +
                "that use alphanumeric argument names.");
        }
        format(0, null, arguments, argsMap, dest, fp);
    }
1018884
def split_args(args):
    
    if not args:
        return {}

    # Handle the old comma separated argument format.
    if len(args) == 1 and not REGEXP_ARGS.search(args[0]):
        args = args[0].split(',')

    # Separate out the key and value for each argument.
    args_dict = {}
    for arg in args:
        split_arg = arg.split('=', 1)
        value = len(split_arg) > 1 and split_arg[1] or None
        args_dict[split_arg[0]] = value

    return args_dict
936173
function normalize(args) {
  let result = {
    queries:  null,
    callback: null
  };

  if (args.length === 1 && Array.isArray(args[0])) {
    result.queries = args[0];
  } else if (args.length === 2 && Array.isArray(args[0])) {
    result.queries = args[0];

    if (typeof args[1] === 'function') {
      result.callback = args[1];
    }
  } else {
    result.queries = args;

    if (typeof result.queries[result.queries.length - 1] === 'function') {
      result.callback = result.queries.pop();
    }
  }

  return result;
}