• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

gturi / nca / 8277672099

14 Mar 2024 08:32AM UTC coverage: 86.091% (+0.1%) from 85.979%
8277672099

push

github

web-flow
Merge pull request #213 from gturi/feature/nca-alias-command

Feature/nca alias command

221 of 316 branches covered (69.94%)

Branch coverage included in aggregate %.

598 of 661 new or added lines in 62 files covered. (90.47%)

1 existing line in 1 file now uncovered.

1116 of 1237 relevant lines covered (90.22%)

1211.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.5
/src/mapper/yargs-handler-builder.ts
1
import yargs from "yargs";
2
import { NcaCommand } from "../model/api/nca-command";
3
import { CommandType } from "../model/api/command-type";
161✔
4
import { StringUtils } from "../util/string-utils";
161✔
5
import { AnyObj } from "../util/custom-types";
6
import { SimpleCommandHandler } from "../command/handler/simple-command-handler";
161✔
7
import { FunctionCommandHandler } from "../command/handler/function-command-handler";
161✔
8
import { ModuleCommandHandler } from "../command/handler/module-command-handler";
161✔
9
import { PathUtils } from "../util/path-utils";
161✔
10
import { CommandHandler } from "../command/handler/command-handler";
11
import { CommandHandlerInput } from "../model/input/command-handler-input";
161✔
12

13
export class YargsHandlerBuilder {
161✔
14

15
  static getHandler<T = AnyObj>(args: yargs.ArgumentsCamelCase<T>, ncaCommand: NcaCommand) {
16
    if (StringUtils.isEmpty(ncaCommand.command)) {
51!
NEW
17
      return;
×
18
    }
19

20
    const commandHandler = this.getCommandHandler(args, ncaCommand);
51✔
21
    if (commandHandler) {
51!
22
      commandHandler.run()
51✔
23
    } else {
NEW
24
      console.error(`Command type not supported ${ncaCommand.commandType}`);
×
25
    }
26
  }
27

28
  private static getCommandHandler<T = AnyObj>(
29
    args: yargs.ArgumentsCamelCase<T>,
30
    ncaCommand: NcaCommand
31
  ): CommandHandler | null {
32
    const commandType = ncaCommand.commandType ?? CommandType.Simple
51✔
33
    const command = ncaCommand.command ?? '';
51!
34

35
    switch (commandType) {
51!
36
      case CommandType.Simple:
37
        return new SimpleCommandHandler(command);
2✔
38
      case CommandType.Function: {
39
        const input = new CommandHandlerInput<T>(args);
43✔
40
        return new FunctionCommandHandler<T>(input, command);
43✔
41
      }
42
      case CommandType.Module: {
43
        const input = new CommandHandlerInput<T>(args);
6✔
44
        const jsModulePath = PathUtils.resolvePath(command, ncaCommand.directory);
6✔
45
        return new ModuleCommandHandler<T>(input, jsModulePath);
6✔
46
      }
47
      default:
48
        return null;
×
49
    }
50
  }
51
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc