1975
}
1976
[kRunYargsParserAndExecuteCommands](
1978
>
shortCircuit?: boolean | null,
1979
>
calledFromCommand?: boolean,
1980
>
commandIndex = 0,
1981
>
helpOnly = false
1982
>
): Arguments | Promise<Arguments> {
1983
>
let skipValidation = !!calledFromCommand || helpOnly;
1984
>
args = args || this.#processArgs;
1985
>
1986
>
this.#options.__ = this.#shim.y18n.__;
1987
>
this.#options.configuration = this[kGetParserConfiguration]();
1988
>
1989
>
const populateDoubleDash = !!this.#options.configuration['populate--'];
1990
>
const config = Object.assign({}, this.#options.configuration, {
1991
>
'populate--': true,
1992
>
});
1993
>
const parsed = this.#shim.Parser.detailed(
1994
>
args,
1995
>
Object.assign({}, this.#options, {
1996
>
configuration: {'parse-positional-numbers': false, ...config},
1997
>
})
1998
>
) as DetailedArguments;
1999
>
2000
>
const argv: Arguments = Object.assign(
2001
>
parsed.argv,
2002
>
this.#parseContext
2003
>
) as Arguments;
2004
>
let argvPromise: Arguments | Promise<Arguments> | undefined = undefined;
2005
>
const aliases = parsed.aliases;
2006
>
2007
>
let helpOptSet = false;
2008
>
let versionOptSet = false;
2009
>
Object.keys(argv).forEach(key => {
2010
>
if (key === this.#helpOpt && argv[key]) {
2011
helpOptSet = true;
2013
versionOptSet = true;
2014
}
2016
>
2017
>
argv.$0 = this.$0;
2018
>
this.parsed = parsed;
2019
>
2020
>
// A single yargs instance may be used multiple times, e.g.
2021
>
// const y = yargs(); y.parse('foo --bar'); yargs.parse('bar --foo').
2022
>
// When a prior parse has completed and a new parse is beginning, we
2023
>
// need to clear the cached help message from the previous parse:
2024
>
if (commandIndex === 0) {
2025
>
this.#usage.clearCachedHelpMessage();
2026
>
}
2027
>
2028
>
try {
2029
>
this[kGuessLocale](); // guess locale lazily, so that it can be turned off in chain.
2030
>
2031
>
// while building up the argv object, there
2032
>
// are two passes through the parser. If completion
2033
>
// is being performed short-circuit on the first pass.
2034
>
if (shortCircuit) {
2035
return this[kPostProcess](
2036
argv,