@travetto/cli 4.0.2 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 ArcSine Technologies
3
+ Copyright (c) 2020 ArcSine Technologies
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/cli",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "description": "CLI infrastructure for Travetto framework",
5
5
  "keywords": [
6
6
  "cli",
package/src/execute.ts CHANGED
@@ -6,6 +6,7 @@ import { CliCommandSchemaUtil } from './schema';
6
6
  import { CliUnknownCommandError, CliValidationResultError } from './error';
7
7
  import { CliParseUtil } from './parse';
8
8
  import { CliUtil } from './util';
9
+ import { CliCommandShape } from './types';
9
10
 
10
11
  /**
11
12
  * Execution manager
@@ -31,8 +32,8 @@ export class ExecutionManager {
31
32
  console.error!();
32
33
  }
33
34
 
34
- /** Run command */
35
- static async #runCommand(cmd: string, args: string[]): Promise<void> {
35
+ /** Bind command */
36
+ static async #bindCommand(cmd: string, args: string[]): Promise<{ command: CliCommandShape, boundArgs: unknown[] }> {
36
37
  const command = await CliCommandRegistry.getInstance(cmd, true);
37
38
  const schema = await CliCommandSchemaUtil.getSchema(command);
38
39
  const fullArgs = await CliParseUtil.expandArgs(schema, args);
@@ -40,6 +41,12 @@ export class ExecutionManager {
40
41
 
41
42
  await command.preBind?.();
42
43
  const boundArgs = await CliCommandSchemaUtil.bindInput(command, state);
44
+ return { command, boundArgs };
45
+ }
46
+
47
+ /** Run command */
48
+ static async #runCommand(cmd: string, args: string[]): Promise<void> {
49
+ const { command, boundArgs } = await this.#bindCommand(cmd, args);
43
50
 
44
51
  await command.preValidate?.();
45
52
  await CliCommandSchemaUtil.validate(command, boundArgs);
@@ -62,7 +69,8 @@ export class ExecutionManager {
62
69
  if (!cmd) {
63
70
  console.info!(await HelpUtil.renderAllHelp());
64
71
  } else if (help) {
65
- console.log!(await HelpUtil.renderCommandHelp(cmd));
72
+ const { command } = await this.#bindCommand(cmd, args)
73
+ console.log!(await HelpUtil.renderCommandHelp(command));
66
74
  } else {
67
75
  await this.#runCommand(cmd, args);
68
76
  }