yargs-factory.ts ×9

Frontier kind: Code frontier

unlabeled · c_2a6d84c916fc

709 tests · 1984 LOC · 18 files · introduces 0 tests · 72 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
10 ranges72 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
356 ranges1984 lines · 18 files · Browse complete extent
All tests (intent)
709 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 72 introduced LOC across 10 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

lib/yargs-factory.ts 71 introduced LOC · 9 ranges

Open complete file

1975 }
1976 [kRunYargsParserAndExecuteCommands](
1977 > args: string | string[] | null, yargs-factory.ts
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;
2012 > } else if (key === this.#versionOpt && argv[key]) { yargs-factory.ts
2013 versionOptSet = true;
2014 }
2015 > }); yargs-factory.ts
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,
2061 const handlerKeys = this.#command.getCommands();
2062
2063 > const requestCompletions = this.#completion?.completionKey yargs-factory.ts
2064 > ? [
2065 this.#completion?.completionKey,
2066 ...(this.getAliases()[this.#completion?.completionKey] ?? []),
2067 ].some((key: string) =>
2068 Object.prototype.hasOwnProperty.call(argv, key)
2069 > ) yargs-factory.ts
2070 > : false;
2071 >
2072 > const skipRecommendation = helpOptSet || requestCompletions || helpOnly;
2073 > if (argv._.length) {
2074 if (handlerKeys.length) {
2075 let firstUnknownCommand;
2131 }
2132
2133 > if (this.#command.hasDefaultCommand() && !skipRecommendation) { yargs-factory.ts
2134 const innerArgv = this.#command.runCommand(
2135 null,
2193
2194 // Check if any of the options to skip validation were provided
2195 > if (!skipValidation && this.#options.skipValidation.length > 0) { yargs-factory.ts
2196 skipValidation = Object.keys(argv).some(
2197 key =>
2230 }
2231 }
2232 > } catch (err) { yargs-factory.ts
2233 if (err instanceof YError) this.#usage.fail(err.message, err);
2234 else throw err;
2236
2237 return this[kPostProcess](
2238 > argvPromise ?? argv, yargs-factory.ts
2239 > populateDoubleDash,
2240 > !!calledFromCommand,
2241 > true
2242 > );
2243 > }
2244 [kRunValidation](
2245 aliases: Dictionary<string[]>,
lib/usage.ts 1 introduced LOC · 1 range

Open complete file

579 // not to be be used by next calls to parse
580 self.clearCachedHelpMessage = function () {
581 > cachedHelpMessage = undefined; usage.ts
582 };
583