viza 1.8.21 → 1.8.22

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.
@@ -1,6 +1,17 @@
1
+ export function getGlobalOptions() {
2
+ return [
3
+ { flags: "--status", description: "Show status only (no execution)" },
4
+ { flags: "--remove-log", description: "Remove execution logs after completion", defaultValue: false },
5
+ { flags: "--self-hosted", description: "Use self-hosted runner (viza-builder)", defaultValue: false }
6
+ ];
7
+ }
1
8
  export function registerGlobalOptions(program) {
2
- program
3
- .option("--status", "Show status only (no execution)")
4
- .option("--remove-log", "Remove execution logs after completion", false)
5
- .option("--self-hosted", "Use self-hosted runner (viza-builder)", false);
9
+ for (const opt of getGlobalOptions()) {
10
+ if (opt.defaultValue !== undefined) {
11
+ program.option(opt.flags, opt.description, opt.defaultValue);
12
+ }
13
+ else {
14
+ program.option(opt.flags, opt.description);
15
+ }
16
+ }
6
17
  }
@@ -1,6 +1,6 @@
1
1
  import { Command } from "commander";
2
2
  import { getCliVersion } from "../core/version.js";
3
- import { registerGlobalOptions } from "./options.js";
3
+ import { registerGlobalOptions, getGlobalOptions } from "./options.js";
4
4
  import { loadDescriptors } from "../commands/loadDescriptors.js";
5
5
  import { buildCommandTree } from "../core/commandRegistry.js";
6
6
  import { renderHint } from "../core/renderHint.js";
@@ -61,6 +61,33 @@ export async function createProgram() {
61
61
  sub.description(node.description || "");
62
62
  parent.addCommand(sub);
63
63
  }
64
+ // Bind global CLI options to every command (Commander does not inherit options)
65
+ for (const opt of getGlobalOptions()) {
66
+ // avoid duplicate flags on the same command
67
+ const already = sub.options?.some((o) => o.flags === opt.flags);
68
+ if (!already) {
69
+ if (opt.defaultValue !== undefined) {
70
+ sub.option(opt.flags, opt.description, opt.defaultValue);
71
+ }
72
+ else {
73
+ sub.option(opt.flags, opt.description);
74
+ }
75
+ }
76
+ }
77
+ // Bind CLI options from descriptor (local options)
78
+ if (node.options?.length) {
79
+ for (const opt of node.options) {
80
+ const already = sub.options?.some((o) => o.flags === opt.flags);
81
+ if (!already) {
82
+ if (opt.defaultValue !== undefined) {
83
+ sub.option(opt.flags, opt.description, opt.defaultValue);
84
+ }
85
+ else {
86
+ sub.option(opt.flags, opt.description);
87
+ }
88
+ }
89
+ }
90
+ }
64
91
  if (node.run) {
65
92
  sub.action(node.run);
66
93
  }
@@ -3,6 +3,12 @@ import { loginAwsCommand } from "./aws.js";
3
3
  const descriptor = {
4
4
  command: "login aws",
5
5
  description: "Login to AWS",
6
+ options: [
7
+ {
8
+ flags: "--ssm",
9
+ description: "Login using SSM flow"
10
+ }
11
+ ],
6
12
  run: loginAwsCommand
7
13
  };
8
14
  registerCommand(descriptor);
@@ -0,0 +1,9 @@
1
+ import { registerCommand } from "../../core/commandRegistry.js";
2
+ import { whoamiCommand } from "./index.js";
3
+ const descriptor = {
4
+ command: "whoami",
5
+ description: "Display current user information and team memberships",
6
+ run: whoamiCommand
7
+ };
8
+ registerCommand(descriptor);
9
+ export default descriptor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viza",
3
- "version": "1.8.21",
3
+ "version": "1.8.22",
4
4
  "type": "module",
5
5
  "description": "Viza unified command line interface",
6
6
  "bin": {