command.ts ×12

Frontier kind: Code frontier

unlabeled · c_3c3a8a6646af

274 tests · 2250 LOC · 18 files · introduces 0 tests · 95 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges95 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
404 ranges2250 lines · 18 files · Browse complete extent
All tests (intent)
274 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.

1 file ranked by introduced lines: 95 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

lib/command.ts 95 introduced LOC · 12 ranges

Open complete file

241 }
242 runCommand(
243 > command: string | null, command.ts
244 > yargs: YargsInstance,
245 > parsed: DetailedArguments,
246 > commandIndex: number,
247 > helpOnly: boolean,
248 > helpOrVersionSet: boolean
249 > ): Arguments | Promise<Arguments> {
250 > const commandHandler =
251 > this.handlers[command!] ||
252 > this.handlers[this.aliasMap[command!]] ||
253 > this.defaultCommand;
254 > const currentContext = yargs.getInternalMethods().getContext();
255 > const parentCommands = currentContext.commands.slice();
256 > const isDefaultCommand = !command;
257 > if (command) {
258 currentContext.commands.push(command);
259 currentContext.fullCommands.push(commandHandler.original);
260 }
261 > const builderResult = this.applyBuilderUpdateUsageAndParse( command.ts
262 > isDefaultCommand,
263 > commandHandler,
264 > yargs,
265 > parsed.aliases,
266 > parentCommands,
267 > commandIndex,
268 > helpOnly,
269 > helpOrVersionSet
270 > );
271 > return isPromise(builderResult)
272 > ? builderResult.then(result =>
273 this.applyMiddlewareAndGetResult(
274 isDefaultCommand,
280 yargs
281 )
282 > ) command.ts
283 > : this.applyMiddlewareAndGetResult(
284 isDefaultCommand,
285 commandHandler,
289 builderResult.aliases,
290 yargs
291 > ); command.ts
292 > }
293 private applyBuilderUpdateUsageAndParse(
294 > isDefaultCommand: boolean, command.ts
295 > commandHandler: CommandHandler,
296 > yargs: YargsInstance,
297 > aliases: Dictionary<string[]>,
298 > parentCommands: string[],
299 > commandIndex: number,
300 > helpOnly: boolean,
301 > helpOrVersionSet: boolean
302 > ):
303 > | {aliases: Dictionary<string[]>; innerArgv: Arguments}
304 > | Promise<{aliases: Dictionary<string[]>; innerArgv: Arguments}> {
305 > const builder = commandHandler.builder;
306 > let innerYargs: YargsInstance = yargs;
307 > if (isCommandBuilderCallback(builder)) {
308 // A function can be provided, which builds
309 // up a yargs chain and possibly returns it.
327 });
328 }
329 > } else if (isCommandBuilderOptionDefinitions(builder)) { command.ts
330 // as a short hand, an object can instead be provided, specifying
331 // the options that a command takes.
346 }
347 private parseAndUpdateUsage(
348 > isDefaultCommand: boolean, command.ts
349 > commandHandler: CommandHandler,
350 > innerYargs: YargsInstance,
351 > parentCommands: string[],
352 > commandIndex: number,
353 > helpOnly: boolean
354 > ):
355 > | {aliases: Dictionary<string[]>; innerArgv: Arguments}
356 > | Promise<{aliases: Dictionary<string[]>; innerArgv: Arguments}> {
357 > // A null command indicates we are running the default command,
358 > // if this is the case, we should show the root usage instructions
359 > // rather than the usage instructions for the nested default command:
360 > if (isDefaultCommand)
361 > innerYargs.getInternalMethods().getUsageInstance().unfreeze(true);
362 > if (this.shouldUpdateUsage(innerYargs)) {
363 innerYargs
364 .getInternalMethods()
372 );
373 }
374 > const innerArgv = innerYargs command.ts
375 > .getInternalMethods()
376 > .runYargsParserAndExecuteCommands(
377 > null,
378 > undefined,
379 > true,
380 > commandIndex,
381 > helpOnly
382 > );
383 >
384 > return isPromise(innerArgv)
385 > ? innerArgv.then(argv => ({
386 aliases: (innerYargs.parsed as DetailedArguments).aliases,
387 innerArgv: argv,
388 }))
389 > : { command.ts
390 > aliases: (innerYargs.parsed as DetailedArguments).aliases,
391 > innerArgv: innerArgv,
392 > };
393 > }
394 private shouldUpdateUsage(yargs: YargsInstance) {
395 return (
483 }
484 private applyMiddlewareAndGetResult(
485 > isDefaultCommand: boolean, command.ts
486 > commandHandler: CommandHandler,
487 > innerArgv: Arguments,
488 > currentContext: Context,
489 > helpOnly: boolean,
490 > aliases: Dictionary<string[]>,
491 > yargs: YargsInstance
492 > ): Arguments | Promise<Arguments> {
493 > let positionalMap: Dictionary<string[]> = {};
494 > // If showHelp() or getHelp() is being run, we should not
495 > // execute middleware or handlers (these may perform expensive operations
496 > // like creating a DB connection).
497 > if (helpOnly) return innerArgv;
498 if (!yargs.getInternalMethods().getHasOutput()) {
499 positionalMap = this.populatePositionals(
528 positionalMap
529 )
530 > ) command.ts
531 > : this.handleValidationAndGetResult(
532 isDefaultCommand,
533 commandHandler,
538 middlewares,
539 positionalMap
540 > ); command.ts
541 > }
542 // transcribe all positional arguments "command <foo> <bar> [apple]"
543 // onto argv.