command.ts ×8

Frontier kind: Code frontier

unlabeled · c_afd9f3823186

215 tests · 2444 LOC · 18 files · introduces 0 tests · 55 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges55 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
441 ranges2444 lines · 18 files · Browse complete extent
All tests (intent)
215 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: 55 introduced LOC across 9 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

lib/command.ts 54 introduced LOC · 8 ranges

Open complete file

497 if (helpOnly) return innerArgv;
498 if (!yargs.getInternalMethods().getHasOutput()) {
499 > positionalMap = this.populatePositionals( command.ts
500 > commandHandler,
501 > innerArgv as Arguments,
502 > currentContext,
503 > yargs
504 > );
505 > }
506 const middlewares = this.globalMiddleware
507 .getMiddleware()
543 // onto argv.
544 private populatePositionals(
545 > commandHandler: CommandHandler, command.ts
546 > argv: Arguments,
547 > context: Context,
548 > yargs: YargsInstance
549 > ) {
550 > argv._ = argv._.slice(context.commands.length); // nuke the current commands
551 > const demanded = commandHandler.demanded.slice(0);
552 > const optional = commandHandler.optional.slice(0);
553 > const positionalMap: Dictionary<string[]> = {};
554 >
555 > this.validation.positionalCount(demanded.length, argv._.length);
556 >
557 > while (demanded.length) {
558 const demand = demanded.shift()!;
559 this.populatePositional(demand, argv, positionalMap);
560 }
561 > command.ts
562 > while (optional.length) {
563 const maybe = optional.shift()!;
564 this.populatePositional(maybe, argv, positionalMap);
565 }
566 > command.ts
567 > argv._ = context.commands.concat(argv._.map(a => '' + a));
568 >
569 > this.postProcessPositionals(
570 > argv,
571 > positionalMap,
572 > this.cmdToParseOptions(commandHandler.original),
573 > yargs
574 > );
575 >
576 > return positionalMap;
577 > }
578
579 private populatePositional(
626 // applying the same parsing logic used for flags.
627 private postProcessPositionals(
628 > argv: Arguments, command.ts
629 > positionalMap: Dictionary<string[]>,
630 > parseOptions: Positionals,
631 > yargs: YargsInstance
632 > ) {
633 > // combine the parsing hints we've inferred from the command
634 > // string with explicitly configured parsing hints.
635 > const options = Object.assign({}, yargs.getOptions());
636 > options.default = Object.assign(parseOptions.default, options.default);
637 > for (const key of Object.keys(parseOptions.alias)) {
638 options.alias[key] = (options.alias[key] || []).concat(
639 parseOptions.alias[key]
640 );
641 }
642 > options.array = options.array.concat(parseOptions.array); command.ts
643 > options.config = {}; // don't load config when processing positionals.
644 >
645 > const unparsed: string[] = [];
646 > Object.keys(positionalMap).forEach(key => {
647 positionalMap[key].map(value => {
648 if (options.configuration['unknown-options-as-args'])
651 unparsed.push(value);
652 });
653 > }); command.ts
654 >
655 > // short-circuit parse.
656 > if (!unparsed.length) return;
657
658 const config: Configuration = Object.assign({}, options.configuration, {
703 });
704 }
705 > } command.ts
706 // Check defaults for key (and camel case version of key)
707 isDefaulted(yargs: YargsInstance, key: string): boolean {
lib/validation.ts 1 introduced LOC · 1 range

Open complete file

87 // positional arguments were provided:
88 self.positionalCount = function positionalCount(required, observed) {
89 > if (observed < required) { validation.ts
90 usage.fail(
91 __n(