qcobjects-cli 2.4.65 → 2.5.103-beta

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.
Files changed (204) hide show
  1. package/.github/workflows/npmpublish-beta.yml +4 -4
  2. package/.github/workflows/npmpublish-lts.yml +4 -4
  3. package/.github/workflows/npmpublish-main.yml +4 -4
  4. package/VERSION +1 -1
  5. package/build-esbuild.js +69 -0
  6. package/eslint.config.mjs +88 -0
  7. package/package.json +74 -46
  8. package/public/browser/backend/com.qcobjects.backend.microservice.static.js +318 -0
  9. package/public/browser/backend/com.qcobjects.backend.microservice.static.js.map +7 -0
  10. package/public/browser/backend/org.qcobjects.backend.php.js +290 -0
  11. package/public/browser/backend/org.qcobjects.backend.php.js.map +7 -0
  12. package/public/browser/com.qcobjects.cli.commands.jira.client_services.js +72 -0
  13. package/public/browser/com.qcobjects.cli.commands.jira.client_services.js.map +7 -0
  14. package/public/browser/com.qcobjects.cli.commands.jira.js +117 -0
  15. package/public/browser/com.qcobjects.cli.commands.jira.js.map +7 -0
  16. package/public/browser/com.qcobjects.cli.commands.js +30 -0
  17. package/public/browser/com.qcobjects.cli.commands.js.map +7 -0
  18. package/public/browser/com.qcobjects.cli.commands.version.js +241 -0
  19. package/public/browser/com.qcobjects.cli.commands.version.js.map +7 -0
  20. package/public/browser/index.js +97 -0
  21. package/public/browser/index.js.map +7 -0
  22. package/public/browser/org.qcobjects.common.pipelog.js +43 -0
  23. package/public/browser/org.qcobjects.common.pipelog.js.map +7 -0
  24. package/public/browser/org.qcobjects.enterprise.commands.js +169 -0
  25. package/public/browser/org.qcobjects.enterprise.commands.js.map +7 -0
  26. package/public/browser/org.quickcorp.qcobjects.api.client_services.js +72 -0
  27. package/public/browser/org.quickcorp.qcobjects.api.client_services.js.map +7 -0
  28. package/public/browser/org.quickcorp.qcobjects.cli.js +3185 -0
  29. package/public/browser/org.quickcorp.qcobjects.cli.js.map +7 -0
  30. package/public/browser/org.quickcorp.qcobjects.collab.server.js +422 -0
  31. package/public/browser/org.quickcorp.qcobjects.collab.server.js.map +7 -0
  32. package/public/browser/org.quickcorp.qcobjects.defaultsettings.js +383 -0
  33. package/public/browser/org.quickcorp.qcobjects.defaultsettings.js.map +7 -0
  34. package/public/browser/org.quickcorp.qcobjects.main.file.js +248 -0
  35. package/public/browser/org.quickcorp.qcobjects.main.file.js.map +7 -0
  36. package/public/browser/org.quickcorp.qcobjects.main.http.gae.server.js +538 -0
  37. package/public/browser/org.quickcorp.qcobjects.main.http.gae.server.js.map +7 -0
  38. package/public/browser/org.quickcorp.qcobjects.main.http.server.js +600 -0
  39. package/public/browser/org.quickcorp.qcobjects.main.http.server.js.map +7 -0
  40. package/public/browser/org.quickcorp.qcobjects.main.http2.server.js +465 -0
  41. package/public/browser/org.quickcorp.qcobjects.main.http2.server.js.map +7 -0
  42. package/public/browser/qcobjects-cli.js +89 -0
  43. package/public/browser/qcobjects-cli.js.map +7 -0
  44. package/public/browser/qcobjects-collab.js +41 -0
  45. package/public/browser/qcobjects-collab.js.map +7 -0
  46. package/public/browser/qcobjects-createcert.js +67 -0
  47. package/public/browser/qcobjects-createcert.js.map +7 -0
  48. package/public/browser/qcobjects-gae-http-server.js +41 -0
  49. package/public/browser/qcobjects-gae-http-server.js.map +7 -0
  50. package/public/browser/qcobjects-http-server.js +41 -0
  51. package/public/browser/qcobjects-http-server.js.map +7 -0
  52. package/public/browser/qcobjects-http2-server.js +44 -0
  53. package/public/browser/qcobjects-http2-server.js.map +7 -0
  54. package/public/browser/qcobjects-shell.js +50 -0
  55. package/public/browser/qcobjects-shell.js.map +7 -0
  56. package/public/browser/types/global/index.d.js +15 -0
  57. package/public/browser/types/global/index.d.js.map +7 -0
  58. package/public/cjs/backend/com.qcobjects.backend.microservice.static.cjs +305 -0
  59. package/public/cjs/backend/com.qcobjects.backend.microservice.static.cjs.map +7 -0
  60. package/public/cjs/backend/org.qcobjects.backend.php.cjs +273 -0
  61. package/public/cjs/backend/org.qcobjects.backend.php.cjs.map +7 -0
  62. package/public/cjs/com.qcobjects.cli.commands.cjs +13 -0
  63. package/public/cjs/com.qcobjects.cli.commands.cjs.map +7 -0
  64. package/public/cjs/com.qcobjects.cli.commands.jira.cjs +100 -0
  65. package/public/cjs/com.qcobjects.cli.commands.jira.cjs.map +7 -0
  66. package/public/cjs/com.qcobjects.cli.commands.jira.client_services.cjs +55 -0
  67. package/public/cjs/com.qcobjects.cli.commands.jira.client_services.cjs.map +7 -0
  68. package/public/cjs/com.qcobjects.cli.commands.version.cjs +224 -0
  69. package/public/cjs/com.qcobjects.cli.commands.version.cjs.map +7 -0
  70. package/public/cjs/index.cjs +89 -0
  71. package/public/cjs/index.cjs.map +7 -0
  72. package/public/cjs/org.qcobjects.common.pipelog.cjs +26 -0
  73. package/public/cjs/org.qcobjects.common.pipelog.cjs.map +7 -0
  74. package/public/cjs/org.qcobjects.enterprise.commands.cjs +152 -0
  75. package/public/cjs/org.qcobjects.enterprise.commands.cjs.map +7 -0
  76. package/public/cjs/org.quickcorp.qcobjects.api.client_services.cjs +55 -0
  77. package/public/cjs/org.quickcorp.qcobjects.api.client_services.cjs.map +7 -0
  78. package/public/cjs/org.quickcorp.qcobjects.cli.cjs +3172 -0
  79. package/public/cjs/org.quickcorp.qcobjects.cli.cjs.map +7 -0
  80. package/public/cjs/org.quickcorp.qcobjects.collab.server.cjs +405 -0
  81. package/public/cjs/org.quickcorp.qcobjects.collab.server.cjs.map +7 -0
  82. package/public/cjs/org.quickcorp.qcobjects.defaultsettings.cjs +366 -0
  83. package/public/cjs/org.quickcorp.qcobjects.defaultsettings.cjs.map +7 -0
  84. package/public/cjs/org.quickcorp.qcobjects.main.file.cjs +235 -0
  85. package/public/cjs/org.quickcorp.qcobjects.main.file.cjs.map +7 -0
  86. package/public/cjs/org.quickcorp.qcobjects.main.http.gae.server.cjs +525 -0
  87. package/public/cjs/org.quickcorp.qcobjects.main.http.gae.server.cjs.map +7 -0
  88. package/public/cjs/org.quickcorp.qcobjects.main.http.server.cjs +587 -0
  89. package/public/cjs/org.quickcorp.qcobjects.main.http.server.cjs.map +7 -0
  90. package/public/cjs/org.quickcorp.qcobjects.main.http2.server.cjs +452 -0
  91. package/public/cjs/org.quickcorp.qcobjects.main.http2.server.cjs.map +7 -0
  92. package/public/cjs/qcobjects-cli.cjs +81 -0
  93. package/public/cjs/qcobjects-cli.cjs.map +7 -0
  94. package/public/cjs/qcobjects-collab.cjs +24 -0
  95. package/public/cjs/qcobjects-collab.cjs.map +7 -0
  96. package/public/cjs/qcobjects-createcert.cjs +50 -0
  97. package/public/cjs/qcobjects-createcert.cjs.map +7 -0
  98. package/public/cjs/qcobjects-gae-http-server.cjs +24 -0
  99. package/public/cjs/qcobjects-gae-http-server.cjs.map +7 -0
  100. package/public/cjs/qcobjects-http-server.cjs +24 -0
  101. package/public/cjs/qcobjects-http-server.cjs.map +7 -0
  102. package/public/cjs/qcobjects-http2-server.cjs +27 -0
  103. package/public/cjs/qcobjects-http2-server.cjs.map +7 -0
  104. package/public/cjs/qcobjects-shell.cjs +34 -0
  105. package/public/cjs/qcobjects-shell.cjs.map +7 -0
  106. package/public/cjs/types/global/index.d.cjs +2 -0
  107. package/public/cjs/types/global/index.d.cjs.map +7 -0
  108. package/public/esm/backend/com.qcobjects.backend.microservice.static.mjs +315 -0
  109. package/public/esm/backend/com.qcobjects.backend.microservice.static.mjs.map +7 -0
  110. package/public/esm/backend/org.qcobjects.backend.php.mjs +287 -0
  111. package/public/esm/backend/org.qcobjects.backend.php.mjs.map +7 -0
  112. package/public/esm/com.qcobjects.cli.commands.jira.client_services.mjs +69 -0
  113. package/public/esm/com.qcobjects.cli.commands.jira.client_services.mjs.map +7 -0
  114. package/public/esm/com.qcobjects.cli.commands.jira.mjs +114 -0
  115. package/public/esm/com.qcobjects.cli.commands.jira.mjs.map +7 -0
  116. package/public/esm/com.qcobjects.cli.commands.mjs +27 -0
  117. package/public/esm/com.qcobjects.cli.commands.mjs.map +7 -0
  118. package/public/esm/com.qcobjects.cli.commands.version.mjs +238 -0
  119. package/public/esm/com.qcobjects.cli.commands.version.mjs.map +7 -0
  120. package/public/esm/index.mjs +78 -0
  121. package/public/esm/index.mjs.map +7 -0
  122. package/public/esm/org.qcobjects.common.pipelog.mjs +40 -0
  123. package/public/esm/org.qcobjects.common.pipelog.mjs.map +7 -0
  124. package/public/esm/org.qcobjects.enterprise.commands.mjs +166 -0
  125. package/public/esm/org.qcobjects.enterprise.commands.mjs.map +7 -0
  126. package/public/esm/org.quickcorp.qcobjects.api.client_services.mjs +69 -0
  127. package/public/esm/org.quickcorp.qcobjects.api.client_services.mjs.map +7 -0
  128. package/public/esm/org.quickcorp.qcobjects.cli.mjs +3182 -0
  129. package/public/esm/org.quickcorp.qcobjects.cli.mjs.map +7 -0
  130. package/public/esm/org.quickcorp.qcobjects.collab.server.mjs +419 -0
  131. package/public/esm/org.quickcorp.qcobjects.collab.server.mjs.map +7 -0
  132. package/public/esm/org.quickcorp.qcobjects.defaultsettings.mjs +380 -0
  133. package/public/esm/org.quickcorp.qcobjects.defaultsettings.mjs.map +7 -0
  134. package/public/esm/org.quickcorp.qcobjects.main.file.mjs +245 -0
  135. package/public/esm/org.quickcorp.qcobjects.main.file.mjs.map +7 -0
  136. package/public/esm/org.quickcorp.qcobjects.main.http.gae.server.mjs +535 -0
  137. package/public/esm/org.quickcorp.qcobjects.main.http.gae.server.mjs.map +7 -0
  138. package/public/esm/org.quickcorp.qcobjects.main.http.server.mjs +597 -0
  139. package/public/esm/org.quickcorp.qcobjects.main.http.server.mjs.map +7 -0
  140. package/public/esm/org.quickcorp.qcobjects.main.http2.server.mjs +462 -0
  141. package/public/esm/org.quickcorp.qcobjects.main.http2.server.mjs.map +7 -0
  142. package/public/esm/qcobjects-cli.mjs +68 -0
  143. package/public/esm/qcobjects-cli.mjs.map +7 -0
  144. package/public/esm/qcobjects-collab.mjs +38 -0
  145. package/public/esm/qcobjects-collab.mjs.map +7 -0
  146. package/public/esm/qcobjects-createcert.mjs +64 -0
  147. package/public/esm/qcobjects-createcert.mjs.map +7 -0
  148. package/public/esm/qcobjects-gae-http-server.mjs +38 -0
  149. package/public/esm/qcobjects-gae-http-server.mjs.map +7 -0
  150. package/public/esm/qcobjects-http-server.mjs +38 -0
  151. package/public/esm/qcobjects-http-server.mjs.map +7 -0
  152. package/public/esm/qcobjects-http2-server.mjs +41 -0
  153. package/public/esm/qcobjects-http2-server.mjs.map +7 -0
  154. package/public/esm/qcobjects-shell.mjs +26 -0
  155. package/public/esm/qcobjects-shell.mjs.map +7 -0
  156. package/public/esm/types/global/index.d.mjs +12 -0
  157. package/public/esm/types/global/index.d.mjs.map +7 -0
  158. package/public/index.d.ts +35 -0
  159. package/spec/support/jasmine.json +7 -4
  160. package/src/backend/{com.qcobjects.backend.microservice.static.js → com.qcobjects.backend.microservice.static.ts} +48 -37
  161. package/src/backend/org.qcobjects.backend.php.ts +348 -0
  162. package/src/{com.qcobjects.cli.commands.jira.client_services.js → com.qcobjects.cli.commands.jira.client_services.ts} +49 -33
  163. package/src/com.qcobjects.cli.commands.jira.ts +147 -0
  164. package/src/com.qcobjects.cli.commands.version.ts +293 -0
  165. package/src/{index.mjs → index.cts} +1 -1
  166. package/src/index.mts +2 -0
  167. package/src/index.ts +1 -1
  168. package/src/{org.qcobjects.common.pipelog.js → org.qcobjects.common.pipelog.ts} +4 -4
  169. package/src/org.qcobjects.enterprise.commands.ts +195 -0
  170. package/src/{org.quickcorp.qcobjects.api.client_services.js → org.quickcorp.qcobjects.api.client_services.ts} +49 -32
  171. package/src/org.quickcorp.qcobjects.cli.ts +533 -0
  172. package/src/org.quickcorp.qcobjects.collab.server.ts +420 -0
  173. package/src/{org.quickcorp.qcobjects.defaultsettings.js → org.quickcorp.qcobjects.defaultsettings.ts} +118 -95
  174. package/src/org.quickcorp.qcobjects.main.file.ts +180 -0
  175. package/src/org.quickcorp.qcobjects.main.http.gae.server.ts +507 -0
  176. package/src/org.quickcorp.qcobjects.main.http.server.ts +551 -0
  177. package/src/org.quickcorp.qcobjects.main.http2.server.ts +419 -0
  178. package/src/{qcobjects-cli.js → qcobjects-cli.ts} +7 -8
  179. package/src/{qcobjects-collab.js → qcobjects-collab.ts} +4 -4
  180. package/src/{qcobjects-createcert.js → qcobjects-createcert.ts} +5 -3
  181. package/src/{qcobjects-gae-http-server.js → qcobjects-gae-http-server.ts} +4 -4
  182. package/src/{qcobjects-http-server.js → qcobjects-http-server.ts} +4 -4
  183. package/src/{qcobjects-http2-server.js → qcobjects-http2-server.ts} +6 -8
  184. package/src/{qcobjects-shell.js → qcobjects-shell.ts} +11 -14
  185. package/src/types/global/index.d.ts +2 -0
  186. package/tsconfig.d.json +45 -3
  187. package/tsconfig.jasmine.json +39 -0
  188. package/tsconfig.json +50 -7
  189. package/.eslintignore +0 -5
  190. package/.eslintrc.cjs +0 -6
  191. package/src/backend/org.qcobjects.backend.php.js +0 -334
  192. package/src/com.qcobjects.cli.commands.jira.js +0 -144
  193. package/src/com.qcobjects.cli.commands.version.js +0 -285
  194. package/src/index.cjs +0 -2
  195. package/src/index.d.ts +0 -2
  196. package/src/org.qcobjects.enterprise.commands.js +0 -194
  197. package/src/org.quickcorp.qcobjects.cli.js +0 -523
  198. package/src/org.quickcorp.qcobjects.collab.server.js +0 -415
  199. package/src/org.quickcorp.qcobjects.main.file.js +0 -159
  200. package/src/org.quickcorp.qcobjects.main.http.gae.server.js +0 -495
  201. package/src/org.quickcorp.qcobjects.main.http.server.js +0 -529
  202. package/src/org.quickcorp.qcobjects.main.http2.server.js +0 -392
  203. /package/spec/{testsSpec.js → testsSpec.ts} +0 -0
  204. /package/src/{com.qcobjects.cli.commands.js → com.qcobjects.cli.commands.ts} +0 -0
@@ -0,0 +1,3182 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
+ }) : x)(function(x) {
7
+ if (typeof require !== "undefined") return require.apply(this, arguments);
8
+ throw Error('Dynamic require of "' + x + '" is not supported');
9
+ });
10
+ var __commonJS = (cb, mod) => function __require2() {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ };
13
+
14
+ // node_modules/commander/lib/error.js
15
+ var require_error = __commonJS({
16
+ "node_modules/commander/lib/error.js"(exports) {
17
+ "use strict";
18
+ var CommanderError = class extends Error {
19
+ static {
20
+ __name(this, "CommanderError");
21
+ }
22
+ /**
23
+ * Constructs the CommanderError class
24
+ * @param {number} exitCode suggested exit code which could be used with process.exit
25
+ * @param {string} code an id string representing the error
26
+ * @param {string} message human-readable description of the error
27
+ * @constructor
28
+ */
29
+ constructor(exitCode, code, message) {
30
+ super(message);
31
+ Error.captureStackTrace(this, this.constructor);
32
+ this.name = this.constructor.name;
33
+ this.code = code;
34
+ this.exitCode = exitCode;
35
+ this.nestedError = void 0;
36
+ }
37
+ };
38
+ var InvalidArgumentError = class extends CommanderError {
39
+ static {
40
+ __name(this, "InvalidArgumentError");
41
+ }
42
+ /**
43
+ * Constructs the InvalidArgumentError class
44
+ * @param {string} [message] explanation of why argument is invalid
45
+ * @constructor
46
+ */
47
+ constructor(message) {
48
+ super(1, "commander.invalidArgument", message);
49
+ Error.captureStackTrace(this, this.constructor);
50
+ this.name = this.constructor.name;
51
+ }
52
+ };
53
+ exports.CommanderError = CommanderError;
54
+ exports.InvalidArgumentError = InvalidArgumentError;
55
+ }
56
+ });
57
+
58
+ // node_modules/commander/lib/argument.js
59
+ var require_argument = __commonJS({
60
+ "node_modules/commander/lib/argument.js"(exports) {
61
+ "use strict";
62
+ var { InvalidArgumentError } = require_error();
63
+ var Argument = class {
64
+ static {
65
+ __name(this, "Argument");
66
+ }
67
+ /**
68
+ * Initialize a new command argument with the given name and description.
69
+ * The default is that the argument is required, and you can explicitly
70
+ * indicate this with <> around the name. Put [] around the name for an optional argument.
71
+ *
72
+ * @param {string} name
73
+ * @param {string} [description]
74
+ */
75
+ constructor(name, description) {
76
+ this.description = description || "";
77
+ this.variadic = false;
78
+ this.parseArg = void 0;
79
+ this.defaultValue = void 0;
80
+ this.defaultValueDescription = void 0;
81
+ this.argChoices = void 0;
82
+ switch (name[0]) {
83
+ case "<":
84
+ this.required = true;
85
+ this._name = name.slice(1, -1);
86
+ break;
87
+ case "[":
88
+ this.required = false;
89
+ this._name = name.slice(1, -1);
90
+ break;
91
+ default:
92
+ this.required = true;
93
+ this._name = name;
94
+ break;
95
+ }
96
+ if (this._name.length > 3 && this._name.slice(-3) === "...") {
97
+ this.variadic = true;
98
+ this._name = this._name.slice(0, -3);
99
+ }
100
+ }
101
+ /**
102
+ * Return argument name.
103
+ *
104
+ * @return {string}
105
+ */
106
+ name() {
107
+ return this._name;
108
+ }
109
+ /**
110
+ * @api private
111
+ */
112
+ _concatValue(value, previous) {
113
+ if (previous === this.defaultValue || !Array.isArray(previous)) {
114
+ return [value];
115
+ }
116
+ return previous.concat(value);
117
+ }
118
+ /**
119
+ * Set the default value, and optionally supply the description to be displayed in the help.
120
+ *
121
+ * @param {any} value
122
+ * @param {string} [description]
123
+ * @return {Argument}
124
+ */
125
+ default(value, description) {
126
+ this.defaultValue = value;
127
+ this.defaultValueDescription = description;
128
+ return this;
129
+ }
130
+ /**
131
+ * Set the custom handler for processing CLI command arguments into argument values.
132
+ *
133
+ * @param {Function} [fn]
134
+ * @return {Argument}
135
+ */
136
+ argParser(fn) {
137
+ this.parseArg = fn;
138
+ return this;
139
+ }
140
+ /**
141
+ * Only allow argument value to be one of choices.
142
+ *
143
+ * @param {string[]} values
144
+ * @return {Argument}
145
+ */
146
+ choices(values) {
147
+ this.argChoices = values.slice();
148
+ this.parseArg = (arg, previous) => {
149
+ if (!this.argChoices.includes(arg)) {
150
+ throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
151
+ }
152
+ if (this.variadic) {
153
+ return this._concatValue(arg, previous);
154
+ }
155
+ return arg;
156
+ };
157
+ return this;
158
+ }
159
+ /**
160
+ * Make argument required.
161
+ */
162
+ argRequired() {
163
+ this.required = true;
164
+ return this;
165
+ }
166
+ /**
167
+ * Make argument optional.
168
+ */
169
+ argOptional() {
170
+ this.required = false;
171
+ return this;
172
+ }
173
+ };
174
+ function humanReadableArgName(arg) {
175
+ const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
176
+ return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
177
+ }
178
+ __name(humanReadableArgName, "humanReadableArgName");
179
+ exports.Argument = Argument;
180
+ exports.humanReadableArgName = humanReadableArgName;
181
+ }
182
+ });
183
+
184
+ // node_modules/commander/lib/help.js
185
+ var require_help = __commonJS({
186
+ "node_modules/commander/lib/help.js"(exports) {
187
+ "use strict";
188
+ var { humanReadableArgName } = require_argument();
189
+ var Help = class {
190
+ static {
191
+ __name(this, "Help");
192
+ }
193
+ constructor() {
194
+ this.helpWidth = void 0;
195
+ this.sortSubcommands = false;
196
+ this.sortOptions = false;
197
+ this.showGlobalOptions = false;
198
+ }
199
+ /**
200
+ * Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
201
+ *
202
+ * @param {Command} cmd
203
+ * @returns {Command[]}
204
+ */
205
+ visibleCommands(cmd) {
206
+ const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
207
+ if (cmd._hasImplicitHelpCommand()) {
208
+ const [, helpName, helpArgs] = cmd._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);
209
+ const helpCommand = cmd.createCommand(helpName).helpOption(false);
210
+ helpCommand.description(cmd._helpCommandDescription);
211
+ if (helpArgs) helpCommand.arguments(helpArgs);
212
+ visibleCommands.push(helpCommand);
213
+ }
214
+ if (this.sortSubcommands) {
215
+ visibleCommands.sort((a, b) => {
216
+ return a.name().localeCompare(b.name());
217
+ });
218
+ }
219
+ return visibleCommands;
220
+ }
221
+ /**
222
+ * Compare options for sort.
223
+ *
224
+ * @param {Option} a
225
+ * @param {Option} b
226
+ * @returns number
227
+ */
228
+ compareOptions(a, b) {
229
+ const getSortKey = /* @__PURE__ */ __name((option) => {
230
+ return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
231
+ }, "getSortKey");
232
+ return getSortKey(a).localeCompare(getSortKey(b));
233
+ }
234
+ /**
235
+ * Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.
236
+ *
237
+ * @param {Command} cmd
238
+ * @returns {Option[]}
239
+ */
240
+ visibleOptions(cmd) {
241
+ const visibleOptions = cmd.options.filter((option) => !option.hidden);
242
+ const showShortHelpFlag = cmd._hasHelpOption && cmd._helpShortFlag && !cmd._findOption(cmd._helpShortFlag);
243
+ const showLongHelpFlag = cmd._hasHelpOption && !cmd._findOption(cmd._helpLongFlag);
244
+ if (showShortHelpFlag || showLongHelpFlag) {
245
+ let helpOption;
246
+ if (!showShortHelpFlag) {
247
+ helpOption = cmd.createOption(cmd._helpLongFlag, cmd._helpDescription);
248
+ } else if (!showLongHelpFlag) {
249
+ helpOption = cmd.createOption(cmd._helpShortFlag, cmd._helpDescription);
250
+ } else {
251
+ helpOption = cmd.createOption(cmd._helpFlags, cmd._helpDescription);
252
+ }
253
+ visibleOptions.push(helpOption);
254
+ }
255
+ if (this.sortOptions) {
256
+ visibleOptions.sort(this.compareOptions);
257
+ }
258
+ return visibleOptions;
259
+ }
260
+ /**
261
+ * Get an array of the visible global options. (Not including help.)
262
+ *
263
+ * @param {Command} cmd
264
+ * @returns {Option[]}
265
+ */
266
+ visibleGlobalOptions(cmd) {
267
+ if (!this.showGlobalOptions) return [];
268
+ const globalOptions = [];
269
+ for (let parentCmd = cmd.parent; parentCmd; parentCmd = parentCmd.parent) {
270
+ const visibleOptions = parentCmd.options.filter((option) => !option.hidden);
271
+ globalOptions.push(...visibleOptions);
272
+ }
273
+ if (this.sortOptions) {
274
+ globalOptions.sort(this.compareOptions);
275
+ }
276
+ return globalOptions;
277
+ }
278
+ /**
279
+ * Get an array of the arguments if any have a description.
280
+ *
281
+ * @param {Command} cmd
282
+ * @returns {Argument[]}
283
+ */
284
+ visibleArguments(cmd) {
285
+ if (cmd._argsDescription) {
286
+ cmd._args.forEach((argument) => {
287
+ argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
288
+ });
289
+ }
290
+ if (cmd._args.find((argument) => argument.description)) {
291
+ return cmd._args;
292
+ }
293
+ return [];
294
+ }
295
+ /**
296
+ * Get the command term to show in the list of subcommands.
297
+ *
298
+ * @param {Command} cmd
299
+ * @returns {string}
300
+ */
301
+ subcommandTerm(cmd) {
302
+ const args = cmd._args.map((arg) => humanReadableArgName(arg)).join(" ");
303
+ return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + // simplistic check for non-help option
304
+ (args ? " " + args : "");
305
+ }
306
+ /**
307
+ * Get the option term to show in the list of options.
308
+ *
309
+ * @param {Option} option
310
+ * @returns {string}
311
+ */
312
+ optionTerm(option) {
313
+ return option.flags;
314
+ }
315
+ /**
316
+ * Get the argument term to show in the list of arguments.
317
+ *
318
+ * @param {Argument} argument
319
+ * @returns {string}
320
+ */
321
+ argumentTerm(argument) {
322
+ return argument.name();
323
+ }
324
+ /**
325
+ * Get the longest command term length.
326
+ *
327
+ * @param {Command} cmd
328
+ * @param {Help} helper
329
+ * @returns {number}
330
+ */
331
+ longestSubcommandTermLength(cmd, helper) {
332
+ return helper.visibleCommands(cmd).reduce((max, command) => {
333
+ return Math.max(max, helper.subcommandTerm(command).length);
334
+ }, 0);
335
+ }
336
+ /**
337
+ * Get the longest option term length.
338
+ *
339
+ * @param {Command} cmd
340
+ * @param {Help} helper
341
+ * @returns {number}
342
+ */
343
+ longestOptionTermLength(cmd, helper) {
344
+ return helper.visibleOptions(cmd).reduce((max, option) => {
345
+ return Math.max(max, helper.optionTerm(option).length);
346
+ }, 0);
347
+ }
348
+ /**
349
+ * Get the longest global option term length.
350
+ *
351
+ * @param {Command} cmd
352
+ * @param {Help} helper
353
+ * @returns {number}
354
+ */
355
+ longestGlobalOptionTermLength(cmd, helper) {
356
+ return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
357
+ return Math.max(max, helper.optionTerm(option).length);
358
+ }, 0);
359
+ }
360
+ /**
361
+ * Get the longest argument term length.
362
+ *
363
+ * @param {Command} cmd
364
+ * @param {Help} helper
365
+ * @returns {number}
366
+ */
367
+ longestArgumentTermLength(cmd, helper) {
368
+ return helper.visibleArguments(cmd).reduce((max, argument) => {
369
+ return Math.max(max, helper.argumentTerm(argument).length);
370
+ }, 0);
371
+ }
372
+ /**
373
+ * Get the command usage to be displayed at the top of the built-in help.
374
+ *
375
+ * @param {Command} cmd
376
+ * @returns {string}
377
+ */
378
+ commandUsage(cmd) {
379
+ let cmdName = cmd._name;
380
+ if (cmd._aliases[0]) {
381
+ cmdName = cmdName + "|" + cmd._aliases[0];
382
+ }
383
+ let parentCmdNames = "";
384
+ for (let parentCmd = cmd.parent; parentCmd; parentCmd = parentCmd.parent) {
385
+ parentCmdNames = parentCmd.name() + " " + parentCmdNames;
386
+ }
387
+ return parentCmdNames + cmdName + " " + cmd.usage();
388
+ }
389
+ /**
390
+ * Get the description for the command.
391
+ *
392
+ * @param {Command} cmd
393
+ * @returns {string}
394
+ */
395
+ commandDescription(cmd) {
396
+ return cmd.description();
397
+ }
398
+ /**
399
+ * Get the subcommand summary to show in the list of subcommands.
400
+ * (Fallback to description for backwards compatibility.)
401
+ *
402
+ * @param {Command} cmd
403
+ * @returns {string}
404
+ */
405
+ subcommandDescription(cmd) {
406
+ return cmd.summary() || cmd.description();
407
+ }
408
+ /**
409
+ * Get the option description to show in the list of options.
410
+ *
411
+ * @param {Option} option
412
+ * @return {string}
413
+ */
414
+ optionDescription(option) {
415
+ const extraInfo = [];
416
+ if (option.argChoices) {
417
+ extraInfo.push(
418
+ // use stringify to match the display of the default value
419
+ `choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
420
+ );
421
+ }
422
+ if (option.defaultValue !== void 0) {
423
+ const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean";
424
+ if (showDefault) {
425
+ extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
426
+ }
427
+ }
428
+ if (option.presetArg !== void 0 && option.optional) {
429
+ extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);
430
+ }
431
+ if (option.envVar !== void 0) {
432
+ extraInfo.push(`env: ${option.envVar}`);
433
+ }
434
+ if (extraInfo.length > 0) {
435
+ return `${option.description} (${extraInfo.join(", ")})`;
436
+ }
437
+ return option.description;
438
+ }
439
+ /**
440
+ * Get the argument description to show in the list of arguments.
441
+ *
442
+ * @param {Argument} argument
443
+ * @return {string}
444
+ */
445
+ argumentDescription(argument) {
446
+ const extraInfo = [];
447
+ if (argument.argChoices) {
448
+ extraInfo.push(
449
+ // use stringify to match the display of the default value
450
+ `choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
451
+ );
452
+ }
453
+ if (argument.defaultValue !== void 0) {
454
+ extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
455
+ }
456
+ if (extraInfo.length > 0) {
457
+ const extraDescripton = `(${extraInfo.join(", ")})`;
458
+ if (argument.description) {
459
+ return `${argument.description} ${extraDescripton}`;
460
+ }
461
+ return extraDescripton;
462
+ }
463
+ return argument.description;
464
+ }
465
+ /**
466
+ * Generate the built-in help text.
467
+ *
468
+ * @param {Command} cmd
469
+ * @param {Help} helper
470
+ * @returns {string}
471
+ */
472
+ formatHelp(cmd, helper) {
473
+ const termWidth = helper.padWidth(cmd, helper);
474
+ const helpWidth = helper.helpWidth || 80;
475
+ const itemIndentWidth = 2;
476
+ const itemSeparatorWidth = 2;
477
+ function formatItem(term, description) {
478
+ if (description) {
479
+ const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
480
+ return helper.wrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth);
481
+ }
482
+ return term;
483
+ }
484
+ __name(formatItem, "formatItem");
485
+ function formatList(textArray) {
486
+ return textArray.join("\n").replace(/^/gm, " ".repeat(itemIndentWidth));
487
+ }
488
+ __name(formatList, "formatList");
489
+ let output = [`Usage: ${helper.commandUsage(cmd)}`, ""];
490
+ const commandDescription = helper.commandDescription(cmd);
491
+ if (commandDescription.length > 0) {
492
+ output = output.concat([helper.wrap(commandDescription, helpWidth, 0), ""]);
493
+ }
494
+ const argumentList = helper.visibleArguments(cmd).map((argument) => {
495
+ return formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument));
496
+ });
497
+ if (argumentList.length > 0) {
498
+ output = output.concat(["Arguments:", formatList(argumentList), ""]);
499
+ }
500
+ const optionList = helper.visibleOptions(cmd).map((option) => {
501
+ return formatItem(helper.optionTerm(option), helper.optionDescription(option));
502
+ });
503
+ if (optionList.length > 0) {
504
+ output = output.concat(["Options:", formatList(optionList), ""]);
505
+ }
506
+ if (this.showGlobalOptions) {
507
+ const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
508
+ return formatItem(helper.optionTerm(option), helper.optionDescription(option));
509
+ });
510
+ if (globalOptionList.length > 0) {
511
+ output = output.concat(["Global Options:", formatList(globalOptionList), ""]);
512
+ }
513
+ }
514
+ const commandList = helper.visibleCommands(cmd).map((cmd2) => {
515
+ return formatItem(helper.subcommandTerm(cmd2), helper.subcommandDescription(cmd2));
516
+ });
517
+ if (commandList.length > 0) {
518
+ output = output.concat(["Commands:", formatList(commandList), ""]);
519
+ }
520
+ return output.join("\n");
521
+ }
522
+ /**
523
+ * Calculate the pad width from the maximum term length.
524
+ *
525
+ * @param {Command} cmd
526
+ * @param {Help} helper
527
+ * @returns {number}
528
+ */
529
+ padWidth(cmd, helper) {
530
+ return Math.max(
531
+ helper.longestOptionTermLength(cmd, helper),
532
+ helper.longestGlobalOptionTermLength(cmd, helper),
533
+ helper.longestSubcommandTermLength(cmd, helper),
534
+ helper.longestArgumentTermLength(cmd, helper)
535
+ );
536
+ }
537
+ /**
538
+ * Wrap the given string to width characters per line, with lines after the first indented.
539
+ * Do not wrap if insufficient room for wrapping (minColumnWidth), or string is manually formatted.
540
+ *
541
+ * @param {string} str
542
+ * @param {number} width
543
+ * @param {number} indent
544
+ * @param {number} [minColumnWidth=40]
545
+ * @return {string}
546
+ *
547
+ */
548
+ wrap(str, width, indent, minColumnWidth = 40) {
549
+ const indents = " \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF";
550
+ const manualIndent = new RegExp(`[\\n][${indents}]+`);
551
+ if (str.match(manualIndent)) return str;
552
+ const columnWidth = width - indent;
553
+ if (columnWidth < minColumnWidth) return str;
554
+ const leadingStr = str.slice(0, indent);
555
+ const columnText = str.slice(indent).replace("\r\n", "\n");
556
+ const indentString = " ".repeat(indent);
557
+ const zeroWidthSpace = "\u200B";
558
+ const breaks = `\\s${zeroWidthSpace}`;
559
+ const regex = new RegExp(`
560
+ |.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`, "g");
561
+ const lines = columnText.match(regex) || [];
562
+ return leadingStr + lines.map((line, i) => {
563
+ if (line === "\n") return "";
564
+ return (i > 0 ? indentString : "") + line.trimEnd();
565
+ }).join("\n");
566
+ }
567
+ };
568
+ exports.Help = Help;
569
+ }
570
+ });
571
+
572
+ // node_modules/commander/lib/option.js
573
+ var require_option = __commonJS({
574
+ "node_modules/commander/lib/option.js"(exports) {
575
+ "use strict";
576
+ var { InvalidArgumentError } = require_error();
577
+ var Option = class {
578
+ static {
579
+ __name(this, "Option");
580
+ }
581
+ /**
582
+ * Initialize a new `Option` with the given `flags` and `description`.
583
+ *
584
+ * @param {string} flags
585
+ * @param {string} [description]
586
+ */
587
+ constructor(flags, description) {
588
+ this.flags = flags;
589
+ this.description = description || "";
590
+ this.required = flags.includes("<");
591
+ this.optional = flags.includes("[");
592
+ this.variadic = /\w\.\.\.[>\]]$/.test(flags);
593
+ this.mandatory = false;
594
+ const optionFlags = splitOptionFlags(flags);
595
+ this.short = optionFlags.shortFlag;
596
+ this.long = optionFlags.longFlag;
597
+ this.negate = false;
598
+ if (this.long) {
599
+ this.negate = this.long.startsWith("--no-");
600
+ }
601
+ this.defaultValue = void 0;
602
+ this.defaultValueDescription = void 0;
603
+ this.presetArg = void 0;
604
+ this.envVar = void 0;
605
+ this.parseArg = void 0;
606
+ this.hidden = false;
607
+ this.argChoices = void 0;
608
+ this.conflictsWith = [];
609
+ this.implied = void 0;
610
+ }
611
+ /**
612
+ * Set the default value, and optionally supply the description to be displayed in the help.
613
+ *
614
+ * @param {any} value
615
+ * @param {string} [description]
616
+ * @return {Option}
617
+ */
618
+ default(value, description) {
619
+ this.defaultValue = value;
620
+ this.defaultValueDescription = description;
621
+ return this;
622
+ }
623
+ /**
624
+ * Preset to use when option used without option-argument, especially optional but also boolean and negated.
625
+ * The custom processing (parseArg) is called.
626
+ *
627
+ * @example
628
+ * new Option('--color').default('GREYSCALE').preset('RGB');
629
+ * new Option('--donate [amount]').preset('20').argParser(parseFloat);
630
+ *
631
+ * @param {any} arg
632
+ * @return {Option}
633
+ */
634
+ preset(arg) {
635
+ this.presetArg = arg;
636
+ return this;
637
+ }
638
+ /**
639
+ * Add option name(s) that conflict with this option.
640
+ * An error will be displayed if conflicting options are found during parsing.
641
+ *
642
+ * @example
643
+ * new Option('--rgb').conflicts('cmyk');
644
+ * new Option('--js').conflicts(['ts', 'jsx']);
645
+ *
646
+ * @param {string | string[]} names
647
+ * @return {Option}
648
+ */
649
+ conflicts(names) {
650
+ this.conflictsWith = this.conflictsWith.concat(names);
651
+ return this;
652
+ }
653
+ /**
654
+ * Specify implied option values for when this option is set and the implied options are not.
655
+ *
656
+ * The custom processing (parseArg) is not called on the implied values.
657
+ *
658
+ * @example
659
+ * program
660
+ * .addOption(new Option('--log', 'write logging information to file'))
661
+ * .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
662
+ *
663
+ * @param {Object} impliedOptionValues
664
+ * @return {Option}
665
+ */
666
+ implies(impliedOptionValues) {
667
+ let newImplied = impliedOptionValues;
668
+ if (typeof impliedOptionValues === "string") {
669
+ newImplied = { [impliedOptionValues]: true };
670
+ }
671
+ this.implied = Object.assign(this.implied || {}, newImplied);
672
+ return this;
673
+ }
674
+ /**
675
+ * Set environment variable to check for option value.
676
+ *
677
+ * An environment variable is only used if when processed the current option value is
678
+ * undefined, or the source of the current value is 'default' or 'config' or 'env'.
679
+ *
680
+ * @param {string} name
681
+ * @return {Option}
682
+ */
683
+ env(name) {
684
+ this.envVar = name;
685
+ return this;
686
+ }
687
+ /**
688
+ * Set the custom handler for processing CLI option arguments into option values.
689
+ *
690
+ * @param {Function} [fn]
691
+ * @return {Option}
692
+ */
693
+ argParser(fn) {
694
+ this.parseArg = fn;
695
+ return this;
696
+ }
697
+ /**
698
+ * Whether the option is mandatory and must have a value after parsing.
699
+ *
700
+ * @param {boolean} [mandatory=true]
701
+ * @return {Option}
702
+ */
703
+ makeOptionMandatory(mandatory = true) {
704
+ this.mandatory = !!mandatory;
705
+ return this;
706
+ }
707
+ /**
708
+ * Hide option in help.
709
+ *
710
+ * @param {boolean} [hide=true]
711
+ * @return {Option}
712
+ */
713
+ hideHelp(hide = true) {
714
+ this.hidden = !!hide;
715
+ return this;
716
+ }
717
+ /**
718
+ * @api private
719
+ */
720
+ _concatValue(value, previous) {
721
+ if (previous === this.defaultValue || !Array.isArray(previous)) {
722
+ return [value];
723
+ }
724
+ return previous.concat(value);
725
+ }
726
+ /**
727
+ * Only allow option value to be one of choices.
728
+ *
729
+ * @param {string[]} values
730
+ * @return {Option}
731
+ */
732
+ choices(values) {
733
+ this.argChoices = values.slice();
734
+ this.parseArg = (arg, previous) => {
735
+ if (!this.argChoices.includes(arg)) {
736
+ throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
737
+ }
738
+ if (this.variadic) {
739
+ return this._concatValue(arg, previous);
740
+ }
741
+ return arg;
742
+ };
743
+ return this;
744
+ }
745
+ /**
746
+ * Return option name.
747
+ *
748
+ * @return {string}
749
+ */
750
+ name() {
751
+ if (this.long) {
752
+ return this.long.replace(/^--/, "");
753
+ }
754
+ return this.short.replace(/^-/, "");
755
+ }
756
+ /**
757
+ * Return option name, in a camelcase format that can be used
758
+ * as a object attribute key.
759
+ *
760
+ * @return {string}
761
+ * @api private
762
+ */
763
+ attributeName() {
764
+ return camelcase(this.name().replace(/^no-/, ""));
765
+ }
766
+ /**
767
+ * Check if `arg` matches the short or long flag.
768
+ *
769
+ * @param {string} arg
770
+ * @return {boolean}
771
+ * @api private
772
+ */
773
+ is(arg) {
774
+ return this.short === arg || this.long === arg;
775
+ }
776
+ /**
777
+ * Return whether a boolean option.
778
+ *
779
+ * Options are one of boolean, negated, required argument, or optional argument.
780
+ *
781
+ * @return {boolean}
782
+ * @api private
783
+ */
784
+ isBoolean() {
785
+ return !this.required && !this.optional && !this.negate;
786
+ }
787
+ };
788
+ var DualOptions = class {
789
+ static {
790
+ __name(this, "DualOptions");
791
+ }
792
+ /**
793
+ * @param {Option[]} options
794
+ */
795
+ constructor(options) {
796
+ this.positiveOptions = /* @__PURE__ */ new Map();
797
+ this.negativeOptions = /* @__PURE__ */ new Map();
798
+ this.dualOptions = /* @__PURE__ */ new Set();
799
+ options.forEach((option) => {
800
+ if (option.negate) {
801
+ this.negativeOptions.set(option.attributeName(), option);
802
+ } else {
803
+ this.positiveOptions.set(option.attributeName(), option);
804
+ }
805
+ });
806
+ this.negativeOptions.forEach((value, key) => {
807
+ if (this.positiveOptions.has(key)) {
808
+ this.dualOptions.add(key);
809
+ }
810
+ });
811
+ }
812
+ /**
813
+ * Did the value come from the option, and not from possible matching dual option?
814
+ *
815
+ * @param {any} value
816
+ * @param {Option} option
817
+ * @returns {boolean}
818
+ */
819
+ valueFromOption(value, option) {
820
+ const optionKey = option.attributeName();
821
+ if (!this.dualOptions.has(optionKey)) return true;
822
+ const preset = this.negativeOptions.get(optionKey).presetArg;
823
+ const negativeValue = preset !== void 0 ? preset : false;
824
+ return option.negate === (negativeValue === value);
825
+ }
826
+ };
827
+ function camelcase(str) {
828
+ return str.split("-").reduce((str2, word) => {
829
+ return str2 + word[0].toUpperCase() + word.slice(1);
830
+ });
831
+ }
832
+ __name(camelcase, "camelcase");
833
+ function splitOptionFlags(flags) {
834
+ let shortFlag;
835
+ let longFlag;
836
+ const flagParts = flags.split(/[ |,]+/);
837
+ if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1])) shortFlag = flagParts.shift();
838
+ longFlag = flagParts.shift();
839
+ if (!shortFlag && /^-[^-]$/.test(longFlag)) {
840
+ shortFlag = longFlag;
841
+ longFlag = void 0;
842
+ }
843
+ return { shortFlag, longFlag };
844
+ }
845
+ __name(splitOptionFlags, "splitOptionFlags");
846
+ exports.Option = Option;
847
+ exports.splitOptionFlags = splitOptionFlags;
848
+ exports.DualOptions = DualOptions;
849
+ }
850
+ });
851
+
852
+ // node_modules/commander/lib/suggestSimilar.js
853
+ var require_suggestSimilar = __commonJS({
854
+ "node_modules/commander/lib/suggestSimilar.js"(exports) {
855
+ "use strict";
856
+ var maxDistance = 3;
857
+ function editDistance(a, b) {
858
+ if (Math.abs(a.length - b.length) > maxDistance) return Math.max(a.length, b.length);
859
+ const d = [];
860
+ for (let i = 0; i <= a.length; i++) {
861
+ d[i] = [i];
862
+ }
863
+ for (let j = 0; j <= b.length; j++) {
864
+ d[0][j] = j;
865
+ }
866
+ for (let j = 1; j <= b.length; j++) {
867
+ for (let i = 1; i <= a.length; i++) {
868
+ let cost = 1;
869
+ if (a[i - 1] === b[j - 1]) {
870
+ cost = 0;
871
+ } else {
872
+ cost = 1;
873
+ }
874
+ d[i][j] = Math.min(
875
+ d[i - 1][j] + 1,
876
+ // deletion
877
+ d[i][j - 1] + 1,
878
+ // insertion
879
+ d[i - 1][j - 1] + cost
880
+ // substitution
881
+ );
882
+ if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
883
+ d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
884
+ }
885
+ }
886
+ }
887
+ return d[a.length][b.length];
888
+ }
889
+ __name(editDistance, "editDistance");
890
+ function suggestSimilar(word, candidates) {
891
+ if (!candidates || candidates.length === 0) return "";
892
+ candidates = Array.from(new Set(candidates));
893
+ const searchingOptions = word.startsWith("--");
894
+ if (searchingOptions) {
895
+ word = word.slice(2);
896
+ candidates = candidates.map((candidate) => candidate.slice(2));
897
+ }
898
+ let similar = [];
899
+ let bestDistance = maxDistance;
900
+ const minSimilarity = 0.4;
901
+ candidates.forEach((candidate) => {
902
+ if (candidate.length <= 1) return;
903
+ const distance = editDistance(word, candidate);
904
+ const length = Math.max(word.length, candidate.length);
905
+ const similarity = (length - distance) / length;
906
+ if (similarity > minSimilarity) {
907
+ if (distance < bestDistance) {
908
+ bestDistance = distance;
909
+ similar = [candidate];
910
+ } else if (distance === bestDistance) {
911
+ similar.push(candidate);
912
+ }
913
+ }
914
+ });
915
+ similar.sort((a, b) => a.localeCompare(b));
916
+ if (searchingOptions) {
917
+ similar = similar.map((candidate) => `--${candidate}`);
918
+ }
919
+ if (similar.length > 1) {
920
+ return `
921
+ (Did you mean one of ${similar.join(", ")}?)`;
922
+ }
923
+ if (similar.length === 1) {
924
+ return `
925
+ (Did you mean ${similar[0]}?)`;
926
+ }
927
+ return "";
928
+ }
929
+ __name(suggestSimilar, "suggestSimilar");
930
+ exports.suggestSimilar = suggestSimilar;
931
+ }
932
+ });
933
+
934
+ // node_modules/commander/lib/command.js
935
+ var require_command = __commonJS({
936
+ "node_modules/commander/lib/command.js"(exports) {
937
+ "use strict";
938
+ var EventEmitter = __require("events").EventEmitter;
939
+ var childProcess = __require("child_process");
940
+ var path = __require("path");
941
+ var fs = __require("fs");
942
+ var process2 = __require("process");
943
+ var { Argument, humanReadableArgName } = require_argument();
944
+ var { CommanderError } = require_error();
945
+ var { Help } = require_help();
946
+ var { Option, splitOptionFlags, DualOptions } = require_option();
947
+ var { suggestSimilar } = require_suggestSimilar();
948
+ var Command = class _Command extends EventEmitter {
949
+ static {
950
+ __name(this, "Command");
951
+ }
952
+ /**
953
+ * Initialize a new `Command`.
954
+ *
955
+ * @param {string} [name]
956
+ */
957
+ constructor(name) {
958
+ super();
959
+ this.commands = [];
960
+ this.options = [];
961
+ this.parent = null;
962
+ this._allowUnknownOption = false;
963
+ this._allowExcessArguments = true;
964
+ this._args = [];
965
+ this.args = [];
966
+ this.rawArgs = [];
967
+ this.processedArgs = [];
968
+ this._scriptPath = null;
969
+ this._name = name || "";
970
+ this._optionValues = {};
971
+ this._optionValueSources = {};
972
+ this._storeOptionsAsProperties = false;
973
+ this._actionHandler = null;
974
+ this._executableHandler = false;
975
+ this._executableFile = null;
976
+ this._executableDir = null;
977
+ this._defaultCommandName = null;
978
+ this._exitCallback = null;
979
+ this._aliases = [];
980
+ this._combineFlagAndOptionalValue = true;
981
+ this._description = "";
982
+ this._summary = "";
983
+ this._argsDescription = void 0;
984
+ this._enablePositionalOptions = false;
985
+ this._passThroughOptions = false;
986
+ this._lifeCycleHooks = {};
987
+ this._showHelpAfterError = false;
988
+ this._showSuggestionAfterError = true;
989
+ this._outputConfiguration = {
990
+ writeOut: /* @__PURE__ */ __name((str) => process2.stdout.write(str), "writeOut"),
991
+ writeErr: /* @__PURE__ */ __name((str) => process2.stderr.write(str), "writeErr"),
992
+ getOutHelpWidth: /* @__PURE__ */ __name(() => process2.stdout.isTTY ? process2.stdout.columns : void 0, "getOutHelpWidth"),
993
+ getErrHelpWidth: /* @__PURE__ */ __name(() => process2.stderr.isTTY ? process2.stderr.columns : void 0, "getErrHelpWidth"),
994
+ outputError: /* @__PURE__ */ __name((str, write) => write(str), "outputError")
995
+ };
996
+ this._hidden = false;
997
+ this._hasHelpOption = true;
998
+ this._helpFlags = "-h, --help";
999
+ this._helpDescription = "display help for command";
1000
+ this._helpShortFlag = "-h";
1001
+ this._helpLongFlag = "--help";
1002
+ this._addImplicitHelpCommand = void 0;
1003
+ this._helpCommandName = "help";
1004
+ this._helpCommandnameAndArgs = "help [command]";
1005
+ this._helpCommandDescription = "display help for command";
1006
+ this._helpConfiguration = {};
1007
+ }
1008
+ /**
1009
+ * Copy settings that are useful to have in common across root command and subcommands.
1010
+ *
1011
+ * (Used internally when adding a command using `.command()` so subcommands inherit parent settings.)
1012
+ *
1013
+ * @param {Command} sourceCommand
1014
+ * @return {Command} `this` command for chaining
1015
+ */
1016
+ copyInheritedSettings(sourceCommand) {
1017
+ this._outputConfiguration = sourceCommand._outputConfiguration;
1018
+ this._hasHelpOption = sourceCommand._hasHelpOption;
1019
+ this._helpFlags = sourceCommand._helpFlags;
1020
+ this._helpDescription = sourceCommand._helpDescription;
1021
+ this._helpShortFlag = sourceCommand._helpShortFlag;
1022
+ this._helpLongFlag = sourceCommand._helpLongFlag;
1023
+ this._helpCommandName = sourceCommand._helpCommandName;
1024
+ this._helpCommandnameAndArgs = sourceCommand._helpCommandnameAndArgs;
1025
+ this._helpCommandDescription = sourceCommand._helpCommandDescription;
1026
+ this._helpConfiguration = sourceCommand._helpConfiguration;
1027
+ this._exitCallback = sourceCommand._exitCallback;
1028
+ this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
1029
+ this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue;
1030
+ this._allowExcessArguments = sourceCommand._allowExcessArguments;
1031
+ this._enablePositionalOptions = sourceCommand._enablePositionalOptions;
1032
+ this._showHelpAfterError = sourceCommand._showHelpAfterError;
1033
+ this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError;
1034
+ return this;
1035
+ }
1036
+ /**
1037
+ * Define a command.
1038
+ *
1039
+ * There are two styles of command: pay attention to where to put the description.
1040
+ *
1041
+ * @example
1042
+ * // Command implemented using action handler (description is supplied separately to `.command`)
1043
+ * program
1044
+ * .command('clone <source> [destination]')
1045
+ * .description('clone a repository into a newly created directory')
1046
+ * .action((source, destination) => {
1047
+ * console.log('clone command called');
1048
+ * });
1049
+ *
1050
+ * // Command implemented using separate executable file (description is second parameter to `.command`)
1051
+ * program
1052
+ * .command('start <service>', 'start named service')
1053
+ * .command('stop [service]', 'stop named service, or all if no name supplied');
1054
+ *
1055
+ * @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
1056
+ * @param {Object|string} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
1057
+ * @param {Object} [execOpts] - configuration options (for executable)
1058
+ * @return {Command} returns new command for action handler, or `this` for executable command
1059
+ */
1060
+ command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
1061
+ let desc = actionOptsOrExecDesc;
1062
+ let opts = execOpts;
1063
+ if (typeof desc === "object" && desc !== null) {
1064
+ opts = desc;
1065
+ desc = null;
1066
+ }
1067
+ opts = opts || {};
1068
+ const [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/);
1069
+ const cmd = this.createCommand(name);
1070
+ if (desc) {
1071
+ cmd.description(desc);
1072
+ cmd._executableHandler = true;
1073
+ }
1074
+ if (opts.isDefault) this._defaultCommandName = cmd._name;
1075
+ cmd._hidden = !!(opts.noHelp || opts.hidden);
1076
+ cmd._executableFile = opts.executableFile || null;
1077
+ if (args) cmd.arguments(args);
1078
+ this.commands.push(cmd);
1079
+ cmd.parent = this;
1080
+ cmd.copyInheritedSettings(this);
1081
+ if (desc) return this;
1082
+ return cmd;
1083
+ }
1084
+ /**
1085
+ * Factory routine to create a new unattached command.
1086
+ *
1087
+ * See .command() for creating an attached subcommand, which uses this routine to
1088
+ * create the command. You can override createCommand to customise subcommands.
1089
+ *
1090
+ * @param {string} [name]
1091
+ * @return {Command} new command
1092
+ */
1093
+ createCommand(name) {
1094
+ return new _Command(name);
1095
+ }
1096
+ /**
1097
+ * You can customise the help with a subclass of Help by overriding createHelp,
1098
+ * or by overriding Help properties using configureHelp().
1099
+ *
1100
+ * @return {Help}
1101
+ */
1102
+ createHelp() {
1103
+ return Object.assign(new Help(), this.configureHelp());
1104
+ }
1105
+ /**
1106
+ * You can customise the help by overriding Help properties using configureHelp(),
1107
+ * or with a subclass of Help by overriding createHelp().
1108
+ *
1109
+ * @param {Object} [configuration] - configuration options
1110
+ * @return {Command|Object} `this` command for chaining, or stored configuration
1111
+ */
1112
+ configureHelp(configuration) {
1113
+ if (configuration === void 0) return this._helpConfiguration;
1114
+ this._helpConfiguration = configuration;
1115
+ return this;
1116
+ }
1117
+ /**
1118
+ * The default output goes to stdout and stderr. You can customise this for special
1119
+ * applications. You can also customise the display of errors by overriding outputError.
1120
+ *
1121
+ * The configuration properties are all functions:
1122
+ *
1123
+ * // functions to change where being written, stdout and stderr
1124
+ * writeOut(str)
1125
+ * writeErr(str)
1126
+ * // matching functions to specify width for wrapping help
1127
+ * getOutHelpWidth()
1128
+ * getErrHelpWidth()
1129
+ * // functions based on what is being written out
1130
+ * outputError(str, write) // used for displaying errors, and not used for displaying help
1131
+ *
1132
+ * @param {Object} [configuration] - configuration options
1133
+ * @return {Command|Object} `this` command for chaining, or stored configuration
1134
+ */
1135
+ configureOutput(configuration) {
1136
+ if (configuration === void 0) return this._outputConfiguration;
1137
+ Object.assign(this._outputConfiguration, configuration);
1138
+ return this;
1139
+ }
1140
+ /**
1141
+ * Display the help or a custom message after an error occurs.
1142
+ *
1143
+ * @param {boolean|string} [displayHelp]
1144
+ * @return {Command} `this` command for chaining
1145
+ */
1146
+ showHelpAfterError(displayHelp = true) {
1147
+ if (typeof displayHelp !== "string") displayHelp = !!displayHelp;
1148
+ this._showHelpAfterError = displayHelp;
1149
+ return this;
1150
+ }
1151
+ /**
1152
+ * Display suggestion of similar commands for unknown commands, or options for unknown options.
1153
+ *
1154
+ * @param {boolean} [displaySuggestion]
1155
+ * @return {Command} `this` command for chaining
1156
+ */
1157
+ showSuggestionAfterError(displaySuggestion = true) {
1158
+ this._showSuggestionAfterError = !!displaySuggestion;
1159
+ return this;
1160
+ }
1161
+ /**
1162
+ * Add a prepared subcommand.
1163
+ *
1164
+ * See .command() for creating an attached subcommand which inherits settings from its parent.
1165
+ *
1166
+ * @param {Command} cmd - new subcommand
1167
+ * @param {Object} [opts] - configuration options
1168
+ * @return {Command} `this` command for chaining
1169
+ */
1170
+ addCommand(cmd, opts) {
1171
+ if (!cmd._name) {
1172
+ throw new Error(`Command passed to .addCommand() must have a name
1173
+ - specify the name in Command constructor or using .name()`);
1174
+ }
1175
+ opts = opts || {};
1176
+ if (opts.isDefault) this._defaultCommandName = cmd._name;
1177
+ if (opts.noHelp || opts.hidden) cmd._hidden = true;
1178
+ this.commands.push(cmd);
1179
+ cmd.parent = this;
1180
+ return this;
1181
+ }
1182
+ /**
1183
+ * Factory routine to create a new unattached argument.
1184
+ *
1185
+ * See .argument() for creating an attached argument, which uses this routine to
1186
+ * create the argument. You can override createArgument to return a custom argument.
1187
+ *
1188
+ * @param {string} name
1189
+ * @param {string} [description]
1190
+ * @return {Argument} new argument
1191
+ */
1192
+ createArgument(name, description) {
1193
+ return new Argument(name, description);
1194
+ }
1195
+ /**
1196
+ * Define argument syntax for command.
1197
+ *
1198
+ * The default is that the argument is required, and you can explicitly
1199
+ * indicate this with <> around the name. Put [] around the name for an optional argument.
1200
+ *
1201
+ * @example
1202
+ * program.argument('<input-file>');
1203
+ * program.argument('[output-file]');
1204
+ *
1205
+ * @param {string} name
1206
+ * @param {string} [description]
1207
+ * @param {Function|*} [fn] - custom argument processing function
1208
+ * @param {*} [defaultValue]
1209
+ * @return {Command} `this` command for chaining
1210
+ */
1211
+ argument(name, description, fn, defaultValue) {
1212
+ const argument = this.createArgument(name, description);
1213
+ if (typeof fn === "function") {
1214
+ argument.default(defaultValue).argParser(fn);
1215
+ } else {
1216
+ argument.default(fn);
1217
+ }
1218
+ this.addArgument(argument);
1219
+ return this;
1220
+ }
1221
+ /**
1222
+ * Define argument syntax for command, adding multiple at once (without descriptions).
1223
+ *
1224
+ * See also .argument().
1225
+ *
1226
+ * @example
1227
+ * program.arguments('<cmd> [env]');
1228
+ *
1229
+ * @param {string} names
1230
+ * @return {Command} `this` command for chaining
1231
+ */
1232
+ arguments(names) {
1233
+ names.split(/ +/).forEach((detail) => {
1234
+ this.argument(detail);
1235
+ });
1236
+ return this;
1237
+ }
1238
+ /**
1239
+ * Define argument syntax for command, adding a prepared argument.
1240
+ *
1241
+ * @param {Argument} argument
1242
+ * @return {Command} `this` command for chaining
1243
+ */
1244
+ addArgument(argument) {
1245
+ const previousArgument = this._args.slice(-1)[0];
1246
+ if (previousArgument && previousArgument.variadic) {
1247
+ throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);
1248
+ }
1249
+ if (argument.required && argument.defaultValue !== void 0 && argument.parseArg === void 0) {
1250
+ throw new Error(`a default value for a required argument is never used: '${argument.name()}'`);
1251
+ }
1252
+ this._args.push(argument);
1253
+ return this;
1254
+ }
1255
+ /**
1256
+ * Override default decision whether to add implicit help command.
1257
+ *
1258
+ * addHelpCommand() // force on
1259
+ * addHelpCommand(false); // force off
1260
+ * addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom details
1261
+ *
1262
+ * @return {Command} `this` command for chaining
1263
+ */
1264
+ addHelpCommand(enableOrNameAndArgs, description) {
1265
+ if (enableOrNameAndArgs === false) {
1266
+ this._addImplicitHelpCommand = false;
1267
+ } else {
1268
+ this._addImplicitHelpCommand = true;
1269
+ if (typeof enableOrNameAndArgs === "string") {
1270
+ this._helpCommandName = enableOrNameAndArgs.split(" ")[0];
1271
+ this._helpCommandnameAndArgs = enableOrNameAndArgs;
1272
+ }
1273
+ this._helpCommandDescription = description || this._helpCommandDescription;
1274
+ }
1275
+ return this;
1276
+ }
1277
+ /**
1278
+ * @return {boolean}
1279
+ * @api private
1280
+ */
1281
+ _hasImplicitHelpCommand() {
1282
+ if (this._addImplicitHelpCommand === void 0) {
1283
+ return this.commands.length && !this._actionHandler && !this._findCommand("help");
1284
+ }
1285
+ return this._addImplicitHelpCommand;
1286
+ }
1287
+ /**
1288
+ * Add hook for life cycle event.
1289
+ *
1290
+ * @param {string} event
1291
+ * @param {Function} listener
1292
+ * @return {Command} `this` command for chaining
1293
+ */
1294
+ hook(event, listener) {
1295
+ const allowedValues = ["preSubcommand", "preAction", "postAction"];
1296
+ if (!allowedValues.includes(event)) {
1297
+ throw new Error(`Unexpected value for event passed to hook : '${event}'.
1298
+ Expecting one of '${allowedValues.join("', '")}'`);
1299
+ }
1300
+ if (this._lifeCycleHooks[event]) {
1301
+ this._lifeCycleHooks[event].push(listener);
1302
+ } else {
1303
+ this._lifeCycleHooks[event] = [listener];
1304
+ }
1305
+ return this;
1306
+ }
1307
+ /**
1308
+ * Register callback to use as replacement for calling process.exit.
1309
+ *
1310
+ * @param {Function} [fn] optional callback which will be passed a CommanderError, defaults to throwing
1311
+ * @return {Command} `this` command for chaining
1312
+ */
1313
+ exitOverride(fn) {
1314
+ if (fn) {
1315
+ this._exitCallback = fn;
1316
+ } else {
1317
+ this._exitCallback = (err) => {
1318
+ if (err.code !== "commander.executeSubCommandAsync") {
1319
+ throw err;
1320
+ } else {
1321
+ }
1322
+ };
1323
+ }
1324
+ return this;
1325
+ }
1326
+ /**
1327
+ * Call process.exit, and _exitCallback if defined.
1328
+ *
1329
+ * @param {number} exitCode exit code for using with process.exit
1330
+ * @param {string} code an id string representing the error
1331
+ * @param {string} message human-readable description of the error
1332
+ * @return never
1333
+ * @api private
1334
+ */
1335
+ _exit(exitCode, code, message) {
1336
+ if (this._exitCallback) {
1337
+ this._exitCallback(new CommanderError(exitCode, code, message));
1338
+ }
1339
+ process2.exit(exitCode);
1340
+ }
1341
+ /**
1342
+ * Register callback `fn` for the command.
1343
+ *
1344
+ * @example
1345
+ * program
1346
+ * .command('serve')
1347
+ * .description('start service')
1348
+ * .action(function() {
1349
+ * // do work here
1350
+ * });
1351
+ *
1352
+ * @param {Function} fn
1353
+ * @return {Command} `this` command for chaining
1354
+ */
1355
+ action(fn) {
1356
+ const listener = /* @__PURE__ */ __name((args) => {
1357
+ const expectedArgsCount = this._args.length;
1358
+ const actionArgs = args.slice(0, expectedArgsCount);
1359
+ if (this._storeOptionsAsProperties) {
1360
+ actionArgs[expectedArgsCount] = this;
1361
+ } else {
1362
+ actionArgs[expectedArgsCount] = this.opts();
1363
+ }
1364
+ actionArgs.push(this);
1365
+ return fn.apply(this, actionArgs);
1366
+ }, "listener");
1367
+ this._actionHandler = listener;
1368
+ return this;
1369
+ }
1370
+ /**
1371
+ * Factory routine to create a new unattached option.
1372
+ *
1373
+ * See .option() for creating an attached option, which uses this routine to
1374
+ * create the option. You can override createOption to return a custom option.
1375
+ *
1376
+ * @param {string} flags
1377
+ * @param {string} [description]
1378
+ * @return {Option} new option
1379
+ */
1380
+ createOption(flags, description) {
1381
+ return new Option(flags, description);
1382
+ }
1383
+ /**
1384
+ * Add an option.
1385
+ *
1386
+ * @param {Option} option
1387
+ * @return {Command} `this` command for chaining
1388
+ */
1389
+ addOption(option) {
1390
+ const oname = option.name();
1391
+ const name = option.attributeName();
1392
+ if (option.negate) {
1393
+ const positiveLongFlag = option.long.replace(/^--no-/, "--");
1394
+ if (!this._findOption(positiveLongFlag)) {
1395
+ this.setOptionValueWithSource(name, option.defaultValue === void 0 ? true : option.defaultValue, "default");
1396
+ }
1397
+ } else if (option.defaultValue !== void 0) {
1398
+ this.setOptionValueWithSource(name, option.defaultValue, "default");
1399
+ }
1400
+ this.options.push(option);
1401
+ const handleOptionValue = /* @__PURE__ */ __name((val, invalidValueMessage, valueSource) => {
1402
+ if (val == null && option.presetArg !== void 0) {
1403
+ val = option.presetArg;
1404
+ }
1405
+ const oldValue = this.getOptionValue(name);
1406
+ if (val !== null && option.parseArg) {
1407
+ try {
1408
+ val = option.parseArg(val, oldValue);
1409
+ } catch (err) {
1410
+ if (err.code === "commander.invalidArgument") {
1411
+ const message = `${invalidValueMessage} ${err.message}`;
1412
+ this.error(message, { exitCode: err.exitCode, code: err.code });
1413
+ }
1414
+ throw err;
1415
+ }
1416
+ } else if (val !== null && option.variadic) {
1417
+ val = option._concatValue(val, oldValue);
1418
+ }
1419
+ if (val == null) {
1420
+ if (option.negate) {
1421
+ val = false;
1422
+ } else if (option.isBoolean() || option.optional) {
1423
+ val = true;
1424
+ } else {
1425
+ val = "";
1426
+ }
1427
+ }
1428
+ this.setOptionValueWithSource(name, val, valueSource);
1429
+ }, "handleOptionValue");
1430
+ this.on("option:" + oname, (val) => {
1431
+ const invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`;
1432
+ handleOptionValue(val, invalidValueMessage, "cli");
1433
+ });
1434
+ if (option.envVar) {
1435
+ this.on("optionEnv:" + oname, (val) => {
1436
+ const invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`;
1437
+ handleOptionValue(val, invalidValueMessage, "env");
1438
+ });
1439
+ }
1440
+ return this;
1441
+ }
1442
+ /**
1443
+ * Internal implementation shared by .option() and .requiredOption()
1444
+ *
1445
+ * @api private
1446
+ */
1447
+ _optionEx(config, flags, description, fn, defaultValue) {
1448
+ if (typeof flags === "object" && flags instanceof Option) {
1449
+ throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");
1450
+ }
1451
+ const option = this.createOption(flags, description);
1452
+ option.makeOptionMandatory(!!config.mandatory);
1453
+ if (typeof fn === "function") {
1454
+ option.default(defaultValue).argParser(fn);
1455
+ } else if (fn instanceof RegExp) {
1456
+ const regex = fn;
1457
+ fn = /* @__PURE__ */ __name((val, def) => {
1458
+ const m = regex.exec(val);
1459
+ return m ? m[0] : def;
1460
+ }, "fn");
1461
+ option.default(defaultValue).argParser(fn);
1462
+ } else {
1463
+ option.default(fn);
1464
+ }
1465
+ return this.addOption(option);
1466
+ }
1467
+ /**
1468
+ * Define option with `flags`, `description` and optional
1469
+ * coercion `fn`.
1470
+ *
1471
+ * The `flags` string contains the short and/or long flags,
1472
+ * separated by comma, a pipe or space. The following are all valid
1473
+ * all will output this way when `--help` is used.
1474
+ *
1475
+ * "-p, --pepper"
1476
+ * "-p|--pepper"
1477
+ * "-p --pepper"
1478
+ *
1479
+ * @example
1480
+ * // simple boolean defaulting to undefined
1481
+ * program.option('-p, --pepper', 'add pepper');
1482
+ *
1483
+ * program.pepper
1484
+ * // => undefined
1485
+ *
1486
+ * --pepper
1487
+ * program.pepper
1488
+ * // => true
1489
+ *
1490
+ * // simple boolean defaulting to true (unless non-negated option is also defined)
1491
+ * program.option('-C, --no-cheese', 'remove cheese');
1492
+ *
1493
+ * program.cheese
1494
+ * // => true
1495
+ *
1496
+ * --no-cheese
1497
+ * program.cheese
1498
+ * // => false
1499
+ *
1500
+ * // required argument
1501
+ * program.option('-C, --chdir <path>', 'change the working directory');
1502
+ *
1503
+ * --chdir /tmp
1504
+ * program.chdir
1505
+ * // => "/tmp"
1506
+ *
1507
+ * // optional argument
1508
+ * program.option('-c, --cheese [type]', 'add cheese [marble]');
1509
+ *
1510
+ * @param {string} flags
1511
+ * @param {string} [description]
1512
+ * @param {Function|*} [fn] - custom option processing function or default value
1513
+ * @param {*} [defaultValue]
1514
+ * @return {Command} `this` command for chaining
1515
+ */
1516
+ option(flags, description, fn, defaultValue) {
1517
+ return this._optionEx({}, flags, description, fn, defaultValue);
1518
+ }
1519
+ /**
1520
+ * Add a required option which must have a value after parsing. This usually means
1521
+ * the option must be specified on the command line. (Otherwise the same as .option().)
1522
+ *
1523
+ * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
1524
+ *
1525
+ * @param {string} flags
1526
+ * @param {string} [description]
1527
+ * @param {Function|*} [fn] - custom option processing function or default value
1528
+ * @param {*} [defaultValue]
1529
+ * @return {Command} `this` command for chaining
1530
+ */
1531
+ requiredOption(flags, description, fn, defaultValue) {
1532
+ return this._optionEx({ mandatory: true }, flags, description, fn, defaultValue);
1533
+ }
1534
+ /**
1535
+ * Alter parsing of short flags with optional values.
1536
+ *
1537
+ * @example
1538
+ * // for `.option('-f,--flag [value]'):
1539
+ * program.combineFlagAndOptionalValue(true); // `-f80` is treated like `--flag=80`, this is the default behaviour
1540
+ * program.combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
1541
+ *
1542
+ * @param {Boolean} [combine=true] - if `true` or omitted, an optional value can be specified directly after the flag.
1543
+ */
1544
+ combineFlagAndOptionalValue(combine = true) {
1545
+ this._combineFlagAndOptionalValue = !!combine;
1546
+ return this;
1547
+ }
1548
+ /**
1549
+ * Allow unknown options on the command line.
1550
+ *
1551
+ * @param {Boolean} [allowUnknown=true] - if `true` or omitted, no error will be thrown
1552
+ * for unknown options.
1553
+ */
1554
+ allowUnknownOption(allowUnknown = true) {
1555
+ this._allowUnknownOption = !!allowUnknown;
1556
+ return this;
1557
+ }
1558
+ /**
1559
+ * Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
1560
+ *
1561
+ * @param {Boolean} [allowExcess=true] - if `true` or omitted, no error will be thrown
1562
+ * for excess arguments.
1563
+ */
1564
+ allowExcessArguments(allowExcess = true) {
1565
+ this._allowExcessArguments = !!allowExcess;
1566
+ return this;
1567
+ }
1568
+ /**
1569
+ * Enable positional options. Positional means global options are specified before subcommands which lets
1570
+ * subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
1571
+ * The default behaviour is non-positional and global options may appear anywhere on the command line.
1572
+ *
1573
+ * @param {Boolean} [positional=true]
1574
+ */
1575
+ enablePositionalOptions(positional = true) {
1576
+ this._enablePositionalOptions = !!positional;
1577
+ return this;
1578
+ }
1579
+ /**
1580
+ * Pass through options that come after command-arguments rather than treat them as command-options,
1581
+ * so actual command-options come before command-arguments. Turning this on for a subcommand requires
1582
+ * positional options to have been enabled on the program (parent commands).
1583
+ * The default behaviour is non-positional and options may appear before or after command-arguments.
1584
+ *
1585
+ * @param {Boolean} [passThrough=true]
1586
+ * for unknown options.
1587
+ */
1588
+ passThroughOptions(passThrough = true) {
1589
+ this._passThroughOptions = !!passThrough;
1590
+ if (!!this.parent && passThrough && !this.parent._enablePositionalOptions) {
1591
+ throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");
1592
+ }
1593
+ return this;
1594
+ }
1595
+ /**
1596
+ * Whether to store option values as properties on command object,
1597
+ * or store separately (specify false). In both cases the option values can be accessed using .opts().
1598
+ *
1599
+ * @param {boolean} [storeAsProperties=true]
1600
+ * @return {Command} `this` command for chaining
1601
+ */
1602
+ storeOptionsAsProperties(storeAsProperties = true) {
1603
+ this._storeOptionsAsProperties = !!storeAsProperties;
1604
+ if (this.options.length) {
1605
+ throw new Error("call .storeOptionsAsProperties() before adding options");
1606
+ }
1607
+ return this;
1608
+ }
1609
+ /**
1610
+ * Retrieve option value.
1611
+ *
1612
+ * @param {string} key
1613
+ * @return {Object} value
1614
+ */
1615
+ getOptionValue(key) {
1616
+ if (this._storeOptionsAsProperties) {
1617
+ return this[key];
1618
+ }
1619
+ return this._optionValues[key];
1620
+ }
1621
+ /**
1622
+ * Store option value.
1623
+ *
1624
+ * @param {string} key
1625
+ * @param {Object} value
1626
+ * @return {Command} `this` command for chaining
1627
+ */
1628
+ setOptionValue(key, value) {
1629
+ return this.setOptionValueWithSource(key, value, void 0);
1630
+ }
1631
+ /**
1632
+ * Store option value and where the value came from.
1633
+ *
1634
+ * @param {string} key
1635
+ * @param {Object} value
1636
+ * @param {string} source - expected values are default/config/env/cli/implied
1637
+ * @return {Command} `this` command for chaining
1638
+ */
1639
+ setOptionValueWithSource(key, value, source) {
1640
+ if (this._storeOptionsAsProperties) {
1641
+ this[key] = value;
1642
+ } else {
1643
+ this._optionValues[key] = value;
1644
+ }
1645
+ this._optionValueSources[key] = source;
1646
+ return this;
1647
+ }
1648
+ /**
1649
+ * Get source of option value.
1650
+ * Expected values are default | config | env | cli | implied
1651
+ *
1652
+ * @param {string} key
1653
+ * @return {string}
1654
+ */
1655
+ getOptionValueSource(key) {
1656
+ return this._optionValueSources[key];
1657
+ }
1658
+ /**
1659
+ * Get source of option value. See also .optsWithGlobals().
1660
+ * Expected values are default | config | env | cli | implied
1661
+ *
1662
+ * @param {string} key
1663
+ * @return {string}
1664
+ */
1665
+ getOptionValueSourceWithGlobals(key) {
1666
+ let source;
1667
+ getCommandAndParents(this).forEach((cmd) => {
1668
+ if (cmd.getOptionValueSource(key) !== void 0) {
1669
+ source = cmd.getOptionValueSource(key);
1670
+ }
1671
+ });
1672
+ return source;
1673
+ }
1674
+ /**
1675
+ * Get user arguments from implied or explicit arguments.
1676
+ * Side-effects: set _scriptPath if args included script. Used for default program name, and subcommand searches.
1677
+ *
1678
+ * @api private
1679
+ */
1680
+ _prepareUserArgs(argv, parseOptions) {
1681
+ if (argv !== void 0 && !Array.isArray(argv)) {
1682
+ throw new Error("first parameter to parse must be array or undefined");
1683
+ }
1684
+ parseOptions = parseOptions || {};
1685
+ if (argv === void 0) {
1686
+ argv = process2.argv;
1687
+ if (process2.versions && process2.versions.electron) {
1688
+ parseOptions.from = "electron";
1689
+ }
1690
+ }
1691
+ this.rawArgs = argv.slice();
1692
+ let userArgs;
1693
+ switch (parseOptions.from) {
1694
+ case void 0:
1695
+ case "node":
1696
+ this._scriptPath = argv[1];
1697
+ userArgs = argv.slice(2);
1698
+ break;
1699
+ case "electron":
1700
+ if (process2.defaultApp) {
1701
+ this._scriptPath = argv[1];
1702
+ userArgs = argv.slice(2);
1703
+ } else {
1704
+ userArgs = argv.slice(1);
1705
+ }
1706
+ break;
1707
+ case "user":
1708
+ userArgs = argv.slice(0);
1709
+ break;
1710
+ default:
1711
+ throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
1712
+ }
1713
+ if (!this._name && this._scriptPath) this.nameFromFilename(this._scriptPath);
1714
+ this._name = this._name || "program";
1715
+ return userArgs;
1716
+ }
1717
+ /**
1718
+ * Parse `argv`, setting options and invoking commands when defined.
1719
+ *
1720
+ * The default expectation is that the arguments are from node and have the application as argv[0]
1721
+ * and the script being run in argv[1], with user parameters after that.
1722
+ *
1723
+ * @example
1724
+ * program.parse(process.argv);
1725
+ * program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
1726
+ * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
1727
+ *
1728
+ * @param {string[]} [argv] - optional, defaults to process.argv
1729
+ * @param {Object} [parseOptions] - optionally specify style of options with from: node/user/electron
1730
+ * @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'
1731
+ * @return {Command} `this` command for chaining
1732
+ */
1733
+ parse(argv, parseOptions) {
1734
+ const userArgs = this._prepareUserArgs(argv, parseOptions);
1735
+ this._parseCommand([], userArgs);
1736
+ return this;
1737
+ }
1738
+ /**
1739
+ * Parse `argv`, setting options and invoking commands when defined.
1740
+ *
1741
+ * Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
1742
+ *
1743
+ * The default expectation is that the arguments are from node and have the application as argv[0]
1744
+ * and the script being run in argv[1], with user parameters after that.
1745
+ *
1746
+ * @example
1747
+ * await program.parseAsync(process.argv);
1748
+ * await program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions
1749
+ * await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
1750
+ *
1751
+ * @param {string[]} [argv]
1752
+ * @param {Object} [parseOptions]
1753
+ * @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'
1754
+ * @return {Promise}
1755
+ */
1756
+ async parseAsync(argv, parseOptions) {
1757
+ const userArgs = this._prepareUserArgs(argv, parseOptions);
1758
+ await this._parseCommand([], userArgs);
1759
+ return this;
1760
+ }
1761
+ /**
1762
+ * Execute a sub-command executable.
1763
+ *
1764
+ * @api private
1765
+ */
1766
+ _executeSubCommand(subcommand, args) {
1767
+ args = args.slice();
1768
+ let launchWithNode = false;
1769
+ const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1770
+ function findFile(baseDir, baseName) {
1771
+ const localBin = path.resolve(baseDir, baseName);
1772
+ if (fs.existsSync(localBin)) return localBin;
1773
+ if (sourceExt.includes(path.extname(baseName))) return void 0;
1774
+ const foundExt = sourceExt.find((ext) => fs.existsSync(`${localBin}${ext}`));
1775
+ if (foundExt) return `${localBin}${foundExt}`;
1776
+ return void 0;
1777
+ }
1778
+ __name(findFile, "findFile");
1779
+ this._checkForMissingMandatoryOptions();
1780
+ this._checkForConflictingOptions();
1781
+ let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`;
1782
+ let executableDir = this._executableDir || "";
1783
+ if (this._scriptPath) {
1784
+ let resolvedScriptPath;
1785
+ try {
1786
+ resolvedScriptPath = fs.realpathSync(this._scriptPath);
1787
+ } catch (err) {
1788
+ resolvedScriptPath = this._scriptPath;
1789
+ }
1790
+ executableDir = path.resolve(path.dirname(resolvedScriptPath), executableDir);
1791
+ }
1792
+ if (executableDir) {
1793
+ let localFile = findFile(executableDir, executableFile);
1794
+ if (!localFile && !subcommand._executableFile && this._scriptPath) {
1795
+ const legacyName = path.basename(this._scriptPath, path.extname(this._scriptPath));
1796
+ if (legacyName !== this._name) {
1797
+ localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
1798
+ }
1799
+ }
1800
+ executableFile = localFile || executableFile;
1801
+ }
1802
+ launchWithNode = sourceExt.includes(path.extname(executableFile));
1803
+ let proc;
1804
+ if (process2.platform !== "win32") {
1805
+ if (launchWithNode) {
1806
+ args.unshift(executableFile);
1807
+ args = incrementNodeInspectorPort(process2.execArgv).concat(args);
1808
+ proc = childProcess.spawn(process2.argv[0], args, { stdio: "inherit" });
1809
+ } else {
1810
+ proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
1811
+ }
1812
+ } else {
1813
+ args.unshift(executableFile);
1814
+ args = incrementNodeInspectorPort(process2.execArgv).concat(args);
1815
+ proc = childProcess.spawn(process2.execPath, args, { stdio: "inherit" });
1816
+ }
1817
+ if (!proc.killed) {
1818
+ const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
1819
+ signals.forEach((signal) => {
1820
+ process2.on(signal, () => {
1821
+ if (proc.killed === false && proc.exitCode === null) {
1822
+ proc.kill(signal);
1823
+ }
1824
+ });
1825
+ });
1826
+ }
1827
+ const exitCallback = this._exitCallback;
1828
+ if (!exitCallback) {
1829
+ proc.on("close", process2.exit.bind(process2));
1830
+ } else {
1831
+ proc.on("close", () => {
1832
+ exitCallback(new CommanderError(process2.exitCode || 0, "commander.executeSubCommandAsync", "(close)"));
1833
+ });
1834
+ }
1835
+ proc.on("error", (err) => {
1836
+ if (err.code === "ENOENT") {
1837
+ const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
1838
+ const executableMissing = `'${executableFile}' does not exist
1839
+ - if '${subcommand._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
1840
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
1841
+ - ${executableDirMessage}`;
1842
+ throw new Error(executableMissing);
1843
+ } else if (err.code === "EACCES") {
1844
+ throw new Error(`'${executableFile}' not executable`);
1845
+ }
1846
+ if (!exitCallback) {
1847
+ process2.exit(1);
1848
+ } else {
1849
+ const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)");
1850
+ wrappedError.nestedError = err;
1851
+ exitCallback(wrappedError);
1852
+ }
1853
+ });
1854
+ this.runningCommand = proc;
1855
+ }
1856
+ /**
1857
+ * @api private
1858
+ */
1859
+ _dispatchSubcommand(commandName, operands, unknown) {
1860
+ const subCommand = this._findCommand(commandName);
1861
+ if (!subCommand) this.help({ error: true });
1862
+ let hookResult;
1863
+ hookResult = this._chainOrCallSubCommandHook(hookResult, subCommand, "preSubcommand");
1864
+ hookResult = this._chainOrCall(hookResult, () => {
1865
+ if (subCommand._executableHandler) {
1866
+ this._executeSubCommand(subCommand, operands.concat(unknown));
1867
+ } else {
1868
+ return subCommand._parseCommand(operands, unknown);
1869
+ }
1870
+ });
1871
+ return hookResult;
1872
+ }
1873
+ /**
1874
+ * Check this.args against expected this._args.
1875
+ *
1876
+ * @api private
1877
+ */
1878
+ _checkNumberOfArguments() {
1879
+ this._args.forEach((arg, i) => {
1880
+ if (arg.required && this.args[i] == null) {
1881
+ this.missingArgument(arg.name());
1882
+ }
1883
+ });
1884
+ if (this._args.length > 0 && this._args[this._args.length - 1].variadic) {
1885
+ return;
1886
+ }
1887
+ if (this.args.length > this._args.length) {
1888
+ this._excessArguments(this.args);
1889
+ }
1890
+ }
1891
+ /**
1892
+ * Process this.args using this._args and save as this.processedArgs!
1893
+ *
1894
+ * @api private
1895
+ */
1896
+ _processArguments() {
1897
+ const myParseArg = /* @__PURE__ */ __name((argument, value, previous) => {
1898
+ let parsedValue = value;
1899
+ if (value !== null && argument.parseArg) {
1900
+ try {
1901
+ parsedValue = argument.parseArg(value, previous);
1902
+ } catch (err) {
1903
+ if (err.code === "commander.invalidArgument") {
1904
+ const message = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'. ${err.message}`;
1905
+ this.error(message, { exitCode: err.exitCode, code: err.code });
1906
+ }
1907
+ throw err;
1908
+ }
1909
+ }
1910
+ return parsedValue;
1911
+ }, "myParseArg");
1912
+ this._checkNumberOfArguments();
1913
+ const processedArgs = [];
1914
+ this._args.forEach((declaredArg, index) => {
1915
+ let value = declaredArg.defaultValue;
1916
+ if (declaredArg.variadic) {
1917
+ if (index < this.args.length) {
1918
+ value = this.args.slice(index);
1919
+ if (declaredArg.parseArg) {
1920
+ value = value.reduce((processed, v) => {
1921
+ return myParseArg(declaredArg, v, processed);
1922
+ }, declaredArg.defaultValue);
1923
+ }
1924
+ } else if (value === void 0) {
1925
+ value = [];
1926
+ }
1927
+ } else if (index < this.args.length) {
1928
+ value = this.args[index];
1929
+ if (declaredArg.parseArg) {
1930
+ value = myParseArg(declaredArg, value, declaredArg.defaultValue);
1931
+ }
1932
+ }
1933
+ processedArgs[index] = value;
1934
+ });
1935
+ this.processedArgs = processedArgs;
1936
+ }
1937
+ /**
1938
+ * Once we have a promise we chain, but call synchronously until then.
1939
+ *
1940
+ * @param {Promise|undefined} promise
1941
+ * @param {Function} fn
1942
+ * @return {Promise|undefined}
1943
+ * @api private
1944
+ */
1945
+ _chainOrCall(promise, fn) {
1946
+ if (promise && promise.then && typeof promise.then === "function") {
1947
+ return promise.then(() => fn());
1948
+ }
1949
+ return fn();
1950
+ }
1951
+ /**
1952
+ *
1953
+ * @param {Promise|undefined} promise
1954
+ * @param {string} event
1955
+ * @return {Promise|undefined}
1956
+ * @api private
1957
+ */
1958
+ _chainOrCallHooks(promise, event) {
1959
+ let result = promise;
1960
+ const hooks = [];
1961
+ getCommandAndParents(this).reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== void 0).forEach((hookedCommand) => {
1962
+ hookedCommand._lifeCycleHooks[event].forEach((callback) => {
1963
+ hooks.push({ hookedCommand, callback });
1964
+ });
1965
+ });
1966
+ if (event === "postAction") {
1967
+ hooks.reverse();
1968
+ }
1969
+ hooks.forEach((hookDetail) => {
1970
+ result = this._chainOrCall(result, () => {
1971
+ return hookDetail.callback(hookDetail.hookedCommand, this);
1972
+ });
1973
+ });
1974
+ return result;
1975
+ }
1976
+ /**
1977
+ *
1978
+ * @param {Promise|undefined} promise
1979
+ * @param {Command} subCommand
1980
+ * @param {string} event
1981
+ * @return {Promise|undefined}
1982
+ * @api private
1983
+ */
1984
+ _chainOrCallSubCommandHook(promise, subCommand, event) {
1985
+ let result = promise;
1986
+ if (this._lifeCycleHooks[event] !== void 0) {
1987
+ this._lifeCycleHooks[event].forEach((hook) => {
1988
+ result = this._chainOrCall(result, () => {
1989
+ return hook(this, subCommand);
1990
+ });
1991
+ });
1992
+ }
1993
+ return result;
1994
+ }
1995
+ /**
1996
+ * Process arguments in context of this command.
1997
+ * Returns action result, in case it is a promise.
1998
+ *
1999
+ * @api private
2000
+ */
2001
+ _parseCommand(operands, unknown) {
2002
+ const parsed = this.parseOptions(unknown);
2003
+ this._parseOptionsEnv();
2004
+ this._parseOptionsImplied();
2005
+ operands = operands.concat(parsed.operands);
2006
+ unknown = parsed.unknown;
2007
+ this.args = operands.concat(unknown);
2008
+ if (operands && this._findCommand(operands[0])) {
2009
+ return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
2010
+ }
2011
+ if (this._hasImplicitHelpCommand() && operands[0] === this._helpCommandName) {
2012
+ if (operands.length === 1) {
2013
+ this.help();
2014
+ }
2015
+ return this._dispatchSubcommand(operands[1], [], [this._helpLongFlag]);
2016
+ }
2017
+ if (this._defaultCommandName) {
2018
+ outputHelpIfRequested(this, unknown);
2019
+ return this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
2020
+ }
2021
+ if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
2022
+ this.help({ error: true });
2023
+ }
2024
+ outputHelpIfRequested(this, parsed.unknown);
2025
+ this._checkForMissingMandatoryOptions();
2026
+ this._checkForConflictingOptions();
2027
+ const checkForUnknownOptions = /* @__PURE__ */ __name(() => {
2028
+ if (parsed.unknown.length > 0) {
2029
+ this.unknownOption(parsed.unknown[0]);
2030
+ }
2031
+ }, "checkForUnknownOptions");
2032
+ const commandEvent = `command:${this.name()}`;
2033
+ if (this._actionHandler) {
2034
+ checkForUnknownOptions();
2035
+ this._processArguments();
2036
+ let actionResult;
2037
+ actionResult = this._chainOrCallHooks(actionResult, "preAction");
2038
+ actionResult = this._chainOrCall(actionResult, () => this._actionHandler(this.processedArgs));
2039
+ if (this.parent) {
2040
+ actionResult = this._chainOrCall(actionResult, () => {
2041
+ this.parent.emit(commandEvent, operands, unknown);
2042
+ });
2043
+ }
2044
+ actionResult = this._chainOrCallHooks(actionResult, "postAction");
2045
+ return actionResult;
2046
+ }
2047
+ if (this.parent && this.parent.listenerCount(commandEvent)) {
2048
+ checkForUnknownOptions();
2049
+ this._processArguments();
2050
+ this.parent.emit(commandEvent, operands, unknown);
2051
+ } else if (operands.length) {
2052
+ if (this._findCommand("*")) {
2053
+ return this._dispatchSubcommand("*", operands, unknown);
2054
+ }
2055
+ if (this.listenerCount("command:*")) {
2056
+ this.emit("command:*", operands, unknown);
2057
+ } else if (this.commands.length) {
2058
+ this.unknownCommand();
2059
+ } else {
2060
+ checkForUnknownOptions();
2061
+ this._processArguments();
2062
+ }
2063
+ } else if (this.commands.length) {
2064
+ checkForUnknownOptions();
2065
+ this.help({ error: true });
2066
+ } else {
2067
+ checkForUnknownOptions();
2068
+ this._processArguments();
2069
+ }
2070
+ }
2071
+ /**
2072
+ * Find matching command.
2073
+ *
2074
+ * @api private
2075
+ */
2076
+ _findCommand(name) {
2077
+ if (!name) return void 0;
2078
+ return this.commands.find((cmd) => cmd._name === name || cmd._aliases.includes(name));
2079
+ }
2080
+ /**
2081
+ * Return an option matching `arg` if any.
2082
+ *
2083
+ * @param {string} arg
2084
+ * @return {Option}
2085
+ * @api private
2086
+ */
2087
+ _findOption(arg) {
2088
+ return this.options.find((option) => option.is(arg));
2089
+ }
2090
+ /**
2091
+ * Display an error message if a mandatory option does not have a value.
2092
+ * Called after checking for help flags in leaf subcommand.
2093
+ *
2094
+ * @api private
2095
+ */
2096
+ _checkForMissingMandatoryOptions() {
2097
+ for (let cmd = this; cmd; cmd = cmd.parent) {
2098
+ cmd.options.forEach((anOption) => {
2099
+ if (anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === void 0) {
2100
+ cmd.missingMandatoryOptionValue(anOption);
2101
+ }
2102
+ });
2103
+ }
2104
+ }
2105
+ /**
2106
+ * Display an error message if conflicting options are used together in this.
2107
+ *
2108
+ * @api private
2109
+ */
2110
+ _checkForConflictingLocalOptions() {
2111
+ const definedNonDefaultOptions = this.options.filter(
2112
+ (option) => {
2113
+ const optionKey = option.attributeName();
2114
+ if (this.getOptionValue(optionKey) === void 0) {
2115
+ return false;
2116
+ }
2117
+ return this.getOptionValueSource(optionKey) !== "default";
2118
+ }
2119
+ );
2120
+ const optionsWithConflicting = definedNonDefaultOptions.filter(
2121
+ (option) => option.conflictsWith.length > 0
2122
+ );
2123
+ optionsWithConflicting.forEach((option) => {
2124
+ const conflictingAndDefined = definedNonDefaultOptions.find(
2125
+ (defined) => option.conflictsWith.includes(defined.attributeName())
2126
+ );
2127
+ if (conflictingAndDefined) {
2128
+ this._conflictingOption(option, conflictingAndDefined);
2129
+ }
2130
+ });
2131
+ }
2132
+ /**
2133
+ * Display an error message if conflicting options are used together.
2134
+ * Called after checking for help flags in leaf subcommand.
2135
+ *
2136
+ * @api private
2137
+ */
2138
+ _checkForConflictingOptions() {
2139
+ for (let cmd = this; cmd; cmd = cmd.parent) {
2140
+ cmd._checkForConflictingLocalOptions();
2141
+ }
2142
+ }
2143
+ /**
2144
+ * Parse options from `argv` removing known options,
2145
+ * and return argv split into operands and unknown arguments.
2146
+ *
2147
+ * Examples:
2148
+ *
2149
+ * argv => operands, unknown
2150
+ * --known kkk op => [op], []
2151
+ * op --known kkk => [op], []
2152
+ * sub --unknown uuu op => [sub], [--unknown uuu op]
2153
+ * sub -- --unknown uuu op => [sub --unknown uuu op], []
2154
+ *
2155
+ * @param {String[]} argv
2156
+ * @return {{operands: String[], unknown: String[]}}
2157
+ */
2158
+ parseOptions(argv) {
2159
+ const operands = [];
2160
+ const unknown = [];
2161
+ let dest = operands;
2162
+ const args = argv.slice();
2163
+ function maybeOption(arg) {
2164
+ return arg.length > 1 && arg[0] === "-";
2165
+ }
2166
+ __name(maybeOption, "maybeOption");
2167
+ let activeVariadicOption = null;
2168
+ while (args.length) {
2169
+ const arg = args.shift();
2170
+ if (arg === "--") {
2171
+ if (dest === unknown) dest.push(arg);
2172
+ dest.push(...args);
2173
+ break;
2174
+ }
2175
+ if (activeVariadicOption && !maybeOption(arg)) {
2176
+ this.emit(`option:${activeVariadicOption.name()}`, arg);
2177
+ continue;
2178
+ }
2179
+ activeVariadicOption = null;
2180
+ if (maybeOption(arg)) {
2181
+ const option = this._findOption(arg);
2182
+ if (option) {
2183
+ if (option.required) {
2184
+ const value = args.shift();
2185
+ if (value === void 0) this.optionMissingArgument(option);
2186
+ this.emit(`option:${option.name()}`, value);
2187
+ } else if (option.optional) {
2188
+ let value = null;
2189
+ if (args.length > 0 && !maybeOption(args[0])) {
2190
+ value = args.shift();
2191
+ }
2192
+ this.emit(`option:${option.name()}`, value);
2193
+ } else {
2194
+ this.emit(`option:${option.name()}`);
2195
+ }
2196
+ activeVariadicOption = option.variadic ? option : null;
2197
+ continue;
2198
+ }
2199
+ }
2200
+ if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
2201
+ const option = this._findOption(`-${arg[1]}`);
2202
+ if (option) {
2203
+ if (option.required || option.optional && this._combineFlagAndOptionalValue) {
2204
+ this.emit(`option:${option.name()}`, arg.slice(2));
2205
+ } else {
2206
+ this.emit(`option:${option.name()}`);
2207
+ args.unshift(`-${arg.slice(2)}`);
2208
+ }
2209
+ continue;
2210
+ }
2211
+ }
2212
+ if (/^--[^=]+=/.test(arg)) {
2213
+ const index = arg.indexOf("=");
2214
+ const option = this._findOption(arg.slice(0, index));
2215
+ if (option && (option.required || option.optional)) {
2216
+ this.emit(`option:${option.name()}`, arg.slice(index + 1));
2217
+ continue;
2218
+ }
2219
+ }
2220
+ if (maybeOption(arg)) {
2221
+ dest = unknown;
2222
+ }
2223
+ if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
2224
+ if (this._findCommand(arg)) {
2225
+ operands.push(arg);
2226
+ if (args.length > 0) unknown.push(...args);
2227
+ break;
2228
+ } else if (arg === this._helpCommandName && this._hasImplicitHelpCommand()) {
2229
+ operands.push(arg);
2230
+ if (args.length > 0) operands.push(...args);
2231
+ break;
2232
+ } else if (this._defaultCommandName) {
2233
+ unknown.push(arg);
2234
+ if (args.length > 0) unknown.push(...args);
2235
+ break;
2236
+ }
2237
+ }
2238
+ if (this._passThroughOptions) {
2239
+ dest.push(arg);
2240
+ if (args.length > 0) dest.push(...args);
2241
+ break;
2242
+ }
2243
+ dest.push(arg);
2244
+ }
2245
+ return { operands, unknown };
2246
+ }
2247
+ /**
2248
+ * Return an object containing local option values as key-value pairs.
2249
+ *
2250
+ * @return {Object}
2251
+ */
2252
+ opts() {
2253
+ if (this._storeOptionsAsProperties) {
2254
+ const result = {};
2255
+ const len = this.options.length;
2256
+ for (let i = 0; i < len; i++) {
2257
+ const key = this.options[i].attributeName();
2258
+ result[key] = key === this._versionOptionName ? this._version : this[key];
2259
+ }
2260
+ return result;
2261
+ }
2262
+ return this._optionValues;
2263
+ }
2264
+ /**
2265
+ * Return an object containing merged local and global option values as key-value pairs.
2266
+ *
2267
+ * @return {Object}
2268
+ */
2269
+ optsWithGlobals() {
2270
+ return getCommandAndParents(this).reduce(
2271
+ (combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()),
2272
+ {}
2273
+ );
2274
+ }
2275
+ /**
2276
+ * Display error message and exit (or call exitOverride).
2277
+ *
2278
+ * @param {string} message
2279
+ * @param {Object} [errorOptions]
2280
+ * @param {string} [errorOptions.code] - an id string representing the error
2281
+ * @param {number} [errorOptions.exitCode] - used with process.exit
2282
+ */
2283
+ error(message, errorOptions) {
2284
+ this._outputConfiguration.outputError(`${message}
2285
+ `, this._outputConfiguration.writeErr);
2286
+ if (typeof this._showHelpAfterError === "string") {
2287
+ this._outputConfiguration.writeErr(`${this._showHelpAfterError}
2288
+ `);
2289
+ } else if (this._showHelpAfterError) {
2290
+ this._outputConfiguration.writeErr("\n");
2291
+ this.outputHelp({ error: true });
2292
+ }
2293
+ const config = errorOptions || {};
2294
+ const exitCode = config.exitCode || 1;
2295
+ const code = config.code || "commander.error";
2296
+ this._exit(exitCode, code, message);
2297
+ }
2298
+ /**
2299
+ * Apply any option related environment variables, if option does
2300
+ * not have a value from cli or client code.
2301
+ *
2302
+ * @api private
2303
+ */
2304
+ _parseOptionsEnv() {
2305
+ this.options.forEach((option) => {
2306
+ if (option.envVar && option.envVar in process2.env) {
2307
+ const optionKey = option.attributeName();
2308
+ if (this.getOptionValue(optionKey) === void 0 || ["default", "config", "env"].includes(this.getOptionValueSource(optionKey))) {
2309
+ if (option.required || option.optional) {
2310
+ this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]);
2311
+ } else {
2312
+ this.emit(`optionEnv:${option.name()}`);
2313
+ }
2314
+ }
2315
+ }
2316
+ });
2317
+ }
2318
+ /**
2319
+ * Apply any implied option values, if option is undefined or default value.
2320
+ *
2321
+ * @api private
2322
+ */
2323
+ _parseOptionsImplied() {
2324
+ const dualHelper = new DualOptions(this.options);
2325
+ const hasCustomOptionValue = /* @__PURE__ */ __name((optionKey) => {
2326
+ return this.getOptionValue(optionKey) !== void 0 && !["default", "implied"].includes(this.getOptionValueSource(optionKey));
2327
+ }, "hasCustomOptionValue");
2328
+ this.options.filter((option) => option.implied !== void 0 && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(this.getOptionValue(option.attributeName()), option)).forEach((option) => {
2329
+ Object.keys(option.implied).filter((impliedKey) => !hasCustomOptionValue(impliedKey)).forEach((impliedKey) => {
2330
+ this.setOptionValueWithSource(impliedKey, option.implied[impliedKey], "implied");
2331
+ });
2332
+ });
2333
+ }
2334
+ /**
2335
+ * Argument `name` is missing.
2336
+ *
2337
+ * @param {string} name
2338
+ * @api private
2339
+ */
2340
+ missingArgument(name) {
2341
+ const message = `error: missing required argument '${name}'`;
2342
+ this.error(message, { code: "commander.missingArgument" });
2343
+ }
2344
+ /**
2345
+ * `Option` is missing an argument.
2346
+ *
2347
+ * @param {Option} option
2348
+ * @api private
2349
+ */
2350
+ optionMissingArgument(option) {
2351
+ const message = `error: option '${option.flags}' argument missing`;
2352
+ this.error(message, { code: "commander.optionMissingArgument" });
2353
+ }
2354
+ /**
2355
+ * `Option` does not have a value, and is a mandatory option.
2356
+ *
2357
+ * @param {Option} option
2358
+ * @api private
2359
+ */
2360
+ missingMandatoryOptionValue(option) {
2361
+ const message = `error: required option '${option.flags}' not specified`;
2362
+ this.error(message, { code: "commander.missingMandatoryOptionValue" });
2363
+ }
2364
+ /**
2365
+ * `Option` conflicts with another option.
2366
+ *
2367
+ * @param {Option} option
2368
+ * @param {Option} conflictingOption
2369
+ * @api private
2370
+ */
2371
+ _conflictingOption(option, conflictingOption) {
2372
+ const findBestOptionFromValue = /* @__PURE__ */ __name((option2) => {
2373
+ const optionKey = option2.attributeName();
2374
+ const optionValue = this.getOptionValue(optionKey);
2375
+ const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
2376
+ const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
2377
+ if (negativeOption && (negativeOption.presetArg === void 0 && optionValue === false || negativeOption.presetArg !== void 0 && optionValue === negativeOption.presetArg)) {
2378
+ return negativeOption;
2379
+ }
2380
+ return positiveOption || option2;
2381
+ }, "findBestOptionFromValue");
2382
+ const getErrorMessage = /* @__PURE__ */ __name((option2) => {
2383
+ const bestOption = findBestOptionFromValue(option2);
2384
+ const optionKey = bestOption.attributeName();
2385
+ const source = this.getOptionValueSource(optionKey);
2386
+ if (source === "env") {
2387
+ return `environment variable '${bestOption.envVar}'`;
2388
+ }
2389
+ return `option '${bestOption.flags}'`;
2390
+ }, "getErrorMessage");
2391
+ const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
2392
+ this.error(message, { code: "commander.conflictingOption" });
2393
+ }
2394
+ /**
2395
+ * Unknown option `flag`.
2396
+ *
2397
+ * @param {string} flag
2398
+ * @api private
2399
+ */
2400
+ unknownOption(flag) {
2401
+ if (this._allowUnknownOption) return;
2402
+ let suggestion = "";
2403
+ if (flag.startsWith("--") && this._showSuggestionAfterError) {
2404
+ let candidateFlags = [];
2405
+ let command = this;
2406
+ do {
2407
+ const moreFlags = command.createHelp().visibleOptions(command).filter((option) => option.long).map((option) => option.long);
2408
+ candidateFlags = candidateFlags.concat(moreFlags);
2409
+ command = command.parent;
2410
+ } while (command && !command._enablePositionalOptions);
2411
+ suggestion = suggestSimilar(flag, candidateFlags);
2412
+ }
2413
+ const message = `error: unknown option '${flag}'${suggestion}`;
2414
+ this.error(message, { code: "commander.unknownOption" });
2415
+ }
2416
+ /**
2417
+ * Excess arguments, more than expected.
2418
+ *
2419
+ * @param {string[]} receivedArgs
2420
+ * @api private
2421
+ */
2422
+ _excessArguments(receivedArgs) {
2423
+ if (this._allowExcessArguments) return;
2424
+ const expected = this._args.length;
2425
+ const s = expected === 1 ? "" : "s";
2426
+ const forSubcommand = this.parent ? ` for '${this.name()}'` : "";
2427
+ const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
2428
+ this.error(message, { code: "commander.excessArguments" });
2429
+ }
2430
+ /**
2431
+ * Unknown command.
2432
+ *
2433
+ * @api private
2434
+ */
2435
+ unknownCommand() {
2436
+ const unknownName = this.args[0];
2437
+ let suggestion = "";
2438
+ if (this._showSuggestionAfterError) {
2439
+ const candidateNames = [];
2440
+ this.createHelp().visibleCommands(this).forEach((command) => {
2441
+ candidateNames.push(command.name());
2442
+ if (command.alias()) candidateNames.push(command.alias());
2443
+ });
2444
+ suggestion = suggestSimilar(unknownName, candidateNames);
2445
+ }
2446
+ const message = `error: unknown command '${unknownName}'${suggestion}`;
2447
+ this.error(message, { code: "commander.unknownCommand" });
2448
+ }
2449
+ /**
2450
+ * Set the program version to `str`.
2451
+ *
2452
+ * This method auto-registers the "-V, --version" flag
2453
+ * which will print the version number when passed.
2454
+ *
2455
+ * You can optionally supply the flags and description to override the defaults.
2456
+ *
2457
+ * @param {string} str
2458
+ * @param {string} [flags]
2459
+ * @param {string} [description]
2460
+ * @return {this | string} `this` command for chaining, or version string if no arguments
2461
+ */
2462
+ version(str, flags, description) {
2463
+ if (str === void 0) return this._version;
2464
+ this._version = str;
2465
+ flags = flags || "-V, --version";
2466
+ description = description || "output the version number";
2467
+ const versionOption = this.createOption(flags, description);
2468
+ this._versionOptionName = versionOption.attributeName();
2469
+ this.options.push(versionOption);
2470
+ this.on("option:" + versionOption.name(), () => {
2471
+ this._outputConfiguration.writeOut(`${str}
2472
+ `);
2473
+ this._exit(0, "commander.version", str);
2474
+ });
2475
+ return this;
2476
+ }
2477
+ /**
2478
+ * Set the description.
2479
+ *
2480
+ * @param {string} [str]
2481
+ * @param {Object} [argsDescription]
2482
+ * @return {string|Command}
2483
+ */
2484
+ description(str, argsDescription) {
2485
+ if (str === void 0 && argsDescription === void 0) return this._description;
2486
+ this._description = str;
2487
+ if (argsDescription) {
2488
+ this._argsDescription = argsDescription;
2489
+ }
2490
+ return this;
2491
+ }
2492
+ /**
2493
+ * Set the summary. Used when listed as subcommand of parent.
2494
+ *
2495
+ * @param {string} [str]
2496
+ * @return {string|Command}
2497
+ */
2498
+ summary(str) {
2499
+ if (str === void 0) return this._summary;
2500
+ this._summary = str;
2501
+ return this;
2502
+ }
2503
+ /**
2504
+ * Set an alias for the command.
2505
+ *
2506
+ * You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
2507
+ *
2508
+ * @param {string} [alias]
2509
+ * @return {string|Command}
2510
+ */
2511
+ alias(alias) {
2512
+ if (alias === void 0) return this._aliases[0];
2513
+ let command = this;
2514
+ if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
2515
+ command = this.commands[this.commands.length - 1];
2516
+ }
2517
+ if (alias === command._name) throw new Error("Command alias can't be the same as its name");
2518
+ command._aliases.push(alias);
2519
+ return this;
2520
+ }
2521
+ /**
2522
+ * Set aliases for the command.
2523
+ *
2524
+ * Only the first alias is shown in the auto-generated help.
2525
+ *
2526
+ * @param {string[]} [aliases]
2527
+ * @return {string[]|Command}
2528
+ */
2529
+ aliases(aliases) {
2530
+ if (aliases === void 0) return this._aliases;
2531
+ aliases.forEach((alias) => this.alias(alias));
2532
+ return this;
2533
+ }
2534
+ /**
2535
+ * Set / get the command usage `str`.
2536
+ *
2537
+ * @param {string} [str]
2538
+ * @return {String|Command}
2539
+ */
2540
+ usage(str) {
2541
+ if (str === void 0) {
2542
+ if (this._usage) return this._usage;
2543
+ const args = this._args.map((arg) => {
2544
+ return humanReadableArgName(arg);
2545
+ });
2546
+ return [].concat(
2547
+ this.options.length || this._hasHelpOption ? "[options]" : [],
2548
+ this.commands.length ? "[command]" : [],
2549
+ this._args.length ? args : []
2550
+ ).join(" ");
2551
+ }
2552
+ this._usage = str;
2553
+ return this;
2554
+ }
2555
+ /**
2556
+ * Get or set the name of the command.
2557
+ *
2558
+ * @param {string} [str]
2559
+ * @return {string|Command}
2560
+ */
2561
+ name(str) {
2562
+ if (str === void 0) return this._name;
2563
+ this._name = str;
2564
+ return this;
2565
+ }
2566
+ /**
2567
+ * Set the name of the command from script filename, such as process.argv[1],
2568
+ * or require.main.filename, or __filename.
2569
+ *
2570
+ * (Used internally and public although not documented in README.)
2571
+ *
2572
+ * @example
2573
+ * program.nameFromFilename(require.main.filename);
2574
+ *
2575
+ * @param {string} filename
2576
+ * @return {Command}
2577
+ */
2578
+ nameFromFilename(filename) {
2579
+ this._name = path.basename(filename, path.extname(filename));
2580
+ return this;
2581
+ }
2582
+ /**
2583
+ * Get or set the directory for searching for executable subcommands of this command.
2584
+ *
2585
+ * @example
2586
+ * program.executableDir(__dirname);
2587
+ * // or
2588
+ * program.executableDir('subcommands');
2589
+ *
2590
+ * @param {string} [path]
2591
+ * @return {string|Command}
2592
+ */
2593
+ executableDir(path2) {
2594
+ if (path2 === void 0) return this._executableDir;
2595
+ this._executableDir = path2;
2596
+ return this;
2597
+ }
2598
+ /**
2599
+ * Return program help documentation.
2600
+ *
2601
+ * @param {{ error: boolean }} [contextOptions] - pass {error:true} to wrap for stderr instead of stdout
2602
+ * @return {string}
2603
+ */
2604
+ helpInformation(contextOptions) {
2605
+ const helper = this.createHelp();
2606
+ if (helper.helpWidth === void 0) {
2607
+ helper.helpWidth = contextOptions && contextOptions.error ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth();
2608
+ }
2609
+ return helper.formatHelp(this, helper);
2610
+ }
2611
+ /**
2612
+ * @api private
2613
+ */
2614
+ _getHelpContext(contextOptions) {
2615
+ contextOptions = contextOptions || {};
2616
+ const context = { error: !!contextOptions.error };
2617
+ let write;
2618
+ if (context.error) {
2619
+ write = /* @__PURE__ */ __name((arg) => this._outputConfiguration.writeErr(arg), "write");
2620
+ } else {
2621
+ write = /* @__PURE__ */ __name((arg) => this._outputConfiguration.writeOut(arg), "write");
2622
+ }
2623
+ context.write = contextOptions.write || write;
2624
+ context.command = this;
2625
+ return context;
2626
+ }
2627
+ /**
2628
+ * Output help information for this command.
2629
+ *
2630
+ * Outputs built-in help, and custom text added using `.addHelpText()`.
2631
+ *
2632
+ * @param {{ error: boolean } | Function} [contextOptions] - pass {error:true} to write to stderr instead of stdout
2633
+ */
2634
+ outputHelp(contextOptions) {
2635
+ let deprecatedCallback;
2636
+ if (typeof contextOptions === "function") {
2637
+ deprecatedCallback = contextOptions;
2638
+ contextOptions = void 0;
2639
+ }
2640
+ const context = this._getHelpContext(contextOptions);
2641
+ getCommandAndParents(this).reverse().forEach((command) => command.emit("beforeAllHelp", context));
2642
+ this.emit("beforeHelp", context);
2643
+ let helpInformation = this.helpInformation(context);
2644
+ if (deprecatedCallback) {
2645
+ helpInformation = deprecatedCallback(helpInformation);
2646
+ if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
2647
+ throw new Error("outputHelp callback must return a string or a Buffer");
2648
+ }
2649
+ }
2650
+ context.write(helpInformation);
2651
+ this.emit(this._helpLongFlag);
2652
+ this.emit("afterHelp", context);
2653
+ getCommandAndParents(this).forEach((command) => command.emit("afterAllHelp", context));
2654
+ }
2655
+ /**
2656
+ * You can pass in flags and a description to override the help
2657
+ * flags and help description for your command. Pass in false to
2658
+ * disable the built-in help option.
2659
+ *
2660
+ * @param {string | boolean} [flags]
2661
+ * @param {string} [description]
2662
+ * @return {Command} `this` command for chaining
2663
+ */
2664
+ helpOption(flags, description) {
2665
+ if (typeof flags === "boolean") {
2666
+ this._hasHelpOption = flags;
2667
+ return this;
2668
+ }
2669
+ this._helpFlags = flags || this._helpFlags;
2670
+ this._helpDescription = description || this._helpDescription;
2671
+ const helpFlags = splitOptionFlags(this._helpFlags);
2672
+ this._helpShortFlag = helpFlags.shortFlag;
2673
+ this._helpLongFlag = helpFlags.longFlag;
2674
+ return this;
2675
+ }
2676
+ /**
2677
+ * Output help information and exit.
2678
+ *
2679
+ * Outputs built-in help, and custom text added using `.addHelpText()`.
2680
+ *
2681
+ * @param {{ error: boolean }} [contextOptions] - pass {error:true} to write to stderr instead of stdout
2682
+ */
2683
+ help(contextOptions) {
2684
+ this.outputHelp(contextOptions);
2685
+ let exitCode = process2.exitCode || 0;
2686
+ if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
2687
+ exitCode = 1;
2688
+ }
2689
+ this._exit(exitCode, "commander.help", "(outputHelp)");
2690
+ }
2691
+ /**
2692
+ * Add additional text to be displayed with the built-in help.
2693
+ *
2694
+ * Position is 'before' or 'after' to affect just this command,
2695
+ * and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
2696
+ *
2697
+ * @param {string} position - before or after built-in help
2698
+ * @param {string | Function} text - string to add, or a function returning a string
2699
+ * @return {Command} `this` command for chaining
2700
+ */
2701
+ addHelpText(position, text) {
2702
+ const allowedValues = ["beforeAll", "before", "after", "afterAll"];
2703
+ if (!allowedValues.includes(position)) {
2704
+ throw new Error(`Unexpected value for position to addHelpText.
2705
+ Expecting one of '${allowedValues.join("', '")}'`);
2706
+ }
2707
+ const helpEvent = `${position}Help`;
2708
+ this.on(helpEvent, (context) => {
2709
+ let helpStr;
2710
+ if (typeof text === "function") {
2711
+ helpStr = text({ error: context.error, command: context.command });
2712
+ } else {
2713
+ helpStr = text;
2714
+ }
2715
+ if (helpStr) {
2716
+ context.write(`${helpStr}
2717
+ `);
2718
+ }
2719
+ });
2720
+ return this;
2721
+ }
2722
+ };
2723
+ function outputHelpIfRequested(cmd, args) {
2724
+ const helpOption = cmd._hasHelpOption && args.find((arg) => arg === cmd._helpLongFlag || arg === cmd._helpShortFlag);
2725
+ if (helpOption) {
2726
+ cmd.outputHelp();
2727
+ cmd._exit(0, "commander.helpDisplayed", "(outputHelp)");
2728
+ }
2729
+ }
2730
+ __name(outputHelpIfRequested, "outputHelpIfRequested");
2731
+ function incrementNodeInspectorPort(args) {
2732
+ return args.map((arg) => {
2733
+ if (!arg.startsWith("--inspect")) {
2734
+ return arg;
2735
+ }
2736
+ let debugOption;
2737
+ let debugHost = "127.0.0.1";
2738
+ let debugPort = "9229";
2739
+ let match;
2740
+ if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
2741
+ debugOption = match[1];
2742
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
2743
+ debugOption = match[1];
2744
+ if (/^\d+$/.test(match[3])) {
2745
+ debugPort = match[3];
2746
+ } else {
2747
+ debugHost = match[3];
2748
+ }
2749
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
2750
+ debugOption = match[1];
2751
+ debugHost = match[3];
2752
+ debugPort = match[4];
2753
+ }
2754
+ if (debugOption && debugPort !== "0") {
2755
+ return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
2756
+ }
2757
+ return arg;
2758
+ });
2759
+ }
2760
+ __name(incrementNodeInspectorPort, "incrementNodeInspectorPort");
2761
+ function getCommandAndParents(startCommand) {
2762
+ const result = [];
2763
+ for (let command = startCommand; command; command = command.parent) {
2764
+ result.push(command);
2765
+ }
2766
+ return result;
2767
+ }
2768
+ __name(getCommandAndParents, "getCommandAndParents");
2769
+ exports.Command = Command;
2770
+ }
2771
+ });
2772
+
2773
+ // node_modules/commander/index.js
2774
+ var require_commander = __commonJS({
2775
+ "node_modules/commander/index.js"(exports, module) {
2776
+ "use strict";
2777
+ var { Argument } = require_argument();
2778
+ var { Command } = require_command();
2779
+ var { CommanderError, InvalidArgumentError } = require_error();
2780
+ var { Help } = require_help();
2781
+ var { Option } = require_option();
2782
+ exports = module.exports = new Command();
2783
+ exports.program = exports;
2784
+ exports.Argument = Argument;
2785
+ exports.Command = Command;
2786
+ exports.CommanderError = CommanderError;
2787
+ exports.Help = Help;
2788
+ exports.InvalidArgumentError = InvalidArgumentError;
2789
+ exports.InvalidOptionArgumentError = InvalidArgumentError;
2790
+ exports.Option = Option;
2791
+ }
2792
+ });
2793
+
2794
+ // src/org.quickcorp.qcobjects.cli.ts
2795
+ var require_org_quickcorp_qcobjects_cli = __commonJS({
2796
+ "src/org.quickcorp.qcobjects.cli.ts"(exports) {
2797
+ var fs = __require("fs");
2798
+ var path = __require("path");
2799
+ var absolutePath = path.resolve(__dirname, "./");
2800
+ var templatePath = path.resolve(__dirname, "./templates/apps/") + "/";
2801
+ var templatePwaPath = path.resolve(__dirname, "./templates/pwa/") + "/";
2802
+ var package_config = __require(absolutePath + "/../package.json");
2803
+ var { exec, execSync } = __require("child_process");
2804
+ var { CONFIG, findPackageNodePath, Import, logger, Package, InheritClass, New, serviceLoader, global, Service, Component } = __require("qcobjects");
2805
+ CONFIG.set("node_modules_path", "./node_modules/");
2806
+ CONFIG.set("qcobjectsnewapp_path", CONFIG.get("node_modules_path") + "/qcobjectsnewapp");
2807
+ var { QCObjectsEnterprise } = __require(absolutePath + "/org.qcobjects.enterprise.commands");
2808
+ var { QuickCorpCloud } = __require(absolutePath + "/org.quickcorp.qcobjects.api.client_services");
2809
+ __require(absolutePath + "/com.qcobjects.cli.commands");
2810
+ var SwitchCommander = class extends InheritClass {
2811
+ static {
2812
+ __name(this, "SwitchCommander");
2813
+ }
2814
+ choiceOption = {
2815
+ generateSw: /* @__PURE__ */ __name((_appName, options) => {
2816
+ const dirPrefix = options.dir;
2817
+ const switchCommander = this;
2818
+ const appName = typeof _appName === "undefined" || _appName === true ? "MyAppName" : _appName;
2819
+ switchCommander.generateServiceWorker(appName, dirPrefix).catch((e) => {
2820
+ logger.warn(`An error ocurred while creating service worker: ${e}`);
2821
+ });
2822
+ }, "generateSw"),
2823
+ create: /* @__PURE__ */ __name((_appName, options) => {
2824
+ const version = global.__get_version__();
2825
+ const switchCommander = this;
2826
+ const appName = typeof _appName === "undefined" || _appName === true ? "MyAppName" : _appName;
2827
+ const _package_json_content = `{
2828
+ "name": "${appName}"
2829
+ "version": "1.0.0",
2830
+ "dependencies":{
2831
+ "qcobjectsnewphp": "latest",
2832
+ "qcobjects": "${version.qcobjects}",
2833
+ "qcobjects-sdk": "^${version.sdk}"
2834
+ }
2835
+ }`;
2836
+ let appTemplateName;
2837
+ if (options.createAmp) {
2838
+ appTemplateName = "qcobjects-ecommerce-amp";
2839
+ } else if (options.createPwa) {
2840
+ appTemplateName = "qcobjectsnewapp";
2841
+ } else if (options.createPhp) {
2842
+ appTemplateName = "qcobjectsnewphp";
2843
+ } else if (options.createCustom) {
2844
+ appTemplateName = options.createCustom;
2845
+ } else {
2846
+ appTemplateName = "qcobjectsnewapp";
2847
+ }
2848
+ CONFIG.set("qcobjectsnewapp_path", CONFIG.get("node_modules_path") + "/" + appTemplateName);
2849
+ const _package_json_template_fname = path.resolve(CONFIG.get("qcobjectsnewapp_path", "qcobjectsnewapp"), "./package.json");
2850
+ const createAppCommand = "npm init -y";
2851
+ const _package_json_file = path.resolve(CONFIG.get("projectPath"), "./package.json");
2852
+ logger.debug("_package_json_file: " + _package_json_file);
2853
+ logger.debug(createAppCommand);
2854
+ exec(createAppCommand, (err, stdout, stderr) => {
2855
+ if (err) {
2856
+ throw Error(err.message);
2857
+ process.exit(1);
2858
+ return;
2859
+ }
2860
+ exec(`npm i --save-dev ${appTemplateName}`, () => {
2861
+ const _package_json_template_file = __require(_package_json_template_fname);
2862
+ _package_json_template_file.name = appName;
2863
+ _package_json_template_file.version = "1.0.0";
2864
+ _package_json_template_file.repository = {};
2865
+ fs.writeFileSync(_package_json_file, JSON.stringify(_package_json_template_file, null, 4));
2866
+ logger.info("Good! App Templates was installed!");
2867
+ console.log(`Starting to copy files from app template ${appTemplateName} to your project...`);
2868
+ switchCommander.copyTemplate(path.resolve(findPackageNodePath(appTemplateName), appTemplateName), path.resolve(CONFIG.get("projectPath"), "./")).then(() => {
2869
+ exec("npm uninstall " + appTemplateName + " --save && npm cache verify", (err2, stdout2, stderr2) => {
2870
+ if (err2) {
2871
+ throw Error(err2.message);
2872
+ process.exit(1);
2873
+ return;
2874
+ }
2875
+ execSync("npm install --save-dev qcobjects-cli ");
2876
+ });
2877
+ exec("npm cache verify && npm i ", (err2, stdout2, stderr2) => {
2878
+ if (err2) {
2879
+ throw Error(err2.message);
2880
+ process.exit(1);
2881
+ return;
2882
+ }
2883
+ logger.info("Good! Your application is done. You can play with QCObjects now!");
2884
+ logger.info("I will create the SSL certificates now. It may take some time...");
2885
+ exec("qcobjects-createcert", (err3, stdout3, stderr3) => {
2886
+ logger.info("Test certificates generated");
2887
+ const githubService = New(Service);
2888
+ githubService.url = "https://raw.githubusercontent.com/QuickCorp/QCObjects/main/.gitignore";
2889
+ githubService.headers = {
2890
+ Accept: "application/vnd.github+json",
2891
+ "X-GitHub-Api-Version": "2022-11-28",
2892
+ "User-Agent": "qcobjects-cli"
2893
+ };
2894
+ githubService.done = () => {
2895
+ };
2896
+ serviceLoader(githubService).then(({ service }) => {
2897
+ fs.writeFileSync(path.resolve(CONFIG.get("projectPath"), "./.gitignore"), service.template);
2898
+ try {
2899
+ execSync("git init");
2900
+ logger.debug("Git initialized.");
2901
+ } catch (e) {
2902
+ logger.debug("Could not initialize git.");
2903
+ }
2904
+ });
2905
+ }).stdout.on("data", function(data) {
2906
+ console.log(data);
2907
+ });
2908
+ }).stdout.on("data", function(data) {
2909
+ console.log(data);
2910
+ });
2911
+ }).catch((e) => {
2912
+ console.log(e);
2913
+ });
2914
+ }).stdout.on("data", function(data) {
2915
+ console.log(data);
2916
+ });
2917
+ }).stdout.on("data", function(data) {
2918
+ console.log("App generation started...");
2919
+ });
2920
+ }, "create"),
2921
+ publish(_appName, _options) {
2922
+ logger.debug("publish is not yet implemented");
2923
+ },
2924
+ upgradeToEnterprise(_appName, _options) {
2925
+ const switchCommander = this;
2926
+ QCObjectsEnterprise.upgrade(switchCommander);
2927
+ }
2928
+ };
2929
+ constructor() {
2930
+ super();
2931
+ this.program = require_commander();
2932
+ }
2933
+ shellCommands(_shell_commands) {
2934
+ return new Promise(function(resolve_all, reject_all) {
2935
+ var _promises_set = _shell_commands.map(
2936
+ function(shell_command) {
2937
+ return new Promise(
2938
+ function(resolve, reject) {
2939
+ logger.debug(shell_command);
2940
+ exec(shell_command, (err, stdout, stderr) => {
2941
+ if (!err) {
2942
+ resolve(stdout);
2943
+ } else {
2944
+ logger.debug(`[FAILED]: ${shell_command}`);
2945
+ logger.debug(`${stderr}`);
2946
+ reject(stderr);
2947
+ }
2948
+ }).stdout.on("data", function(data) {
2949
+ logger.info(data);
2950
+ });
2951
+ }
2952
+ ).catch((e) => reject_all(e));
2953
+ }
2954
+ );
2955
+ var _promise_all = Promise.all(_promises_set).then(function(response) {
2956
+ resolve_all(response);
2957
+ }).catch(function(e) {
2958
+ reject_all(e);
2959
+ });
2960
+ }).catch((e) => console.log(e));
2961
+ }
2962
+ fileListRecursive(dir) {
2963
+ var instance = this;
2964
+ return fs.statSync(dir).isDirectory() ? Array.prototype.concat(...fs.readdirSync(dir).map((f) => instance.fileListRecursive(path.join(dir, f)))).filter((f) => {
2965
+ return !f.startsWith(".git") && f.lastIndexOf(".DS_Store") == -1;
2966
+ }) : dir;
2967
+ }
2968
+ register(email, phonenumber) {
2969
+ return new Promise(function(resolve, reject) {
2970
+ logger.info("I'm going to register your profile on the cloud...");
2971
+ const cloudClient = New(QuickCorpCloud, {
2972
+ apiMethod: "register",
2973
+ data: { email, phonenumber }
2974
+ });
2975
+ try {
2976
+ const service = serviceLoader(cloudClient).then((successResonse) => {
2977
+ const template = successResonse.service.template;
2978
+ const response = JSON.parse(template);
2979
+ resolve(response);
2980
+ }).catch((e) => {
2981
+ console.log("\u{1F926} Something went wrong \u{1F926} when trying to register you in the cloud");
2982
+ reject(e);
2983
+ });
2984
+ } catch (e) {
2985
+ console.log("\u{1F926} Something went wrong \u{1F926} when trying to register you in the cloud");
2986
+ reject(e);
2987
+ }
2988
+ });
2989
+ }
2990
+ generateServiceWorker(appName, dirPrefix = "./") {
2991
+ const writeContent = /* @__PURE__ */ __name((component) => {
2992
+ const parsedText = component.parseTemplate(component.template);
2993
+ logger.debug("Starting to write the sw file...");
2994
+ fs.writeFile(`${dirPrefix}/sw.js`, parsedText, (err) => {
2995
+ if (err) {
2996
+ throw Error(err);
2997
+ }
2998
+ logger.info("Service Worker Generated");
2999
+ console.log("");
3000
+ console.log("Now simply put:");
3001
+ console.log("CONFIG.set('serviceWorkerURI','/sw.js');");
3002
+ console.log(" In your init.js file ");
3003
+ console.log("");
3004
+ console.log("To start your app in a local server ");
3005
+ console.log("Execute the command: ");
3006
+ console.log("> qcobjects launch <appname>");
3007
+ console.log("");
3008
+ });
3009
+ }, "writeContent");
3010
+ class ServiceWorkerComponent extends Component {
3011
+ static {
3012
+ __name(this, "ServiceWorkerComponent");
3013
+ }
3014
+ cached = false;
3015
+ templateURI = "sw.js";
3016
+ basePath = templatePwaPath;
3017
+ name = "sw";
3018
+ tplsource = "default";
3019
+ template = "";
3020
+ constructor({ name, data }) {
3021
+ super({ name, data });
3022
+ }
3023
+ done({ request, component }) {
3024
+ super.done({ request, component });
3025
+ writeContent(component);
3026
+ }
3027
+ }
3028
+ return new Promise((resolve, reject) => {
3029
+ var filelist = ["/"].concat(this.fileListRecursive(`${dirPrefix}`));
3030
+ if (typeof dirPrefix !== "undefined" && dirPrefix !== "./" && dirPrefix !== ".") {
3031
+ filelist = filelist.map((f) => f.replace(new RegExp(`${dirPrefix}/`), ""));
3032
+ }
3033
+ filelist = filelist.filter(function(fl) {
3034
+ return fl !== "sw.js" && !fl.startsWith("node_modules/");
3035
+ });
3036
+ filelist = filelist.filter((fname) => !fname.endsWith(".pem"));
3037
+ filelist = filelist.filter((fname) => !fname.endsWith(".sh"));
3038
+ filelist = filelist.filter((fname) => !new RegExp("^package(.*).json$").test(fname));
3039
+ filelist = filelist.filter((fname) => !fname.startsWith("."));
3040
+ var fileListString = '\n "' + filelist.join('",\n "') + '"';
3041
+ const component = new ServiceWorkerComponent({
3042
+ name: "sw",
3043
+ data: {
3044
+ appName,
3045
+ appVersion: "1.0.0",
3046
+ filelist: fileListString
3047
+ }
3048
+ });
3049
+ setTimeout(() => {
3050
+ component.done({ request: null, component });
3051
+ }, 1e3);
3052
+ });
3053
+ }
3054
+ copyTemplate(source, dest) {
3055
+ return new Promise((resolve, reject) => {
3056
+ const copyDir = /* @__PURE__ */ __name((source2, dest2, exclude) => {
3057
+ source2 = path.resolve(source2);
3058
+ dest2 = path.resolve(dest2);
3059
+ const dname = path.basename(source2);
3060
+ const dirExcluded = exclude.includes(dname);
3061
+ const isDir = /* @__PURE__ */ __name((d) => {
3062
+ return fs.existsSync(d) && fs.statSync(d).isDirectory() ? true : false;
3063
+ }, "isDir");
3064
+ const isFile = /* @__PURE__ */ __name((d) => {
3065
+ return fs.existsSync(d) && fs.statSync(d).isFile() ? true : false;
3066
+ }, "isFile");
3067
+ if (isDir(source2) && !dirExcluded) {
3068
+ fs.mkdirSync(dest2, { recursive: true });
3069
+ const paths = fs.readdirSync(source2, { withFileTypes: true });
3070
+ const dirs = paths.filter((d) => d.isDirectory());
3071
+ const files = paths.filter((f) => f.isFile());
3072
+ ((paths2, dirs2, files2, exclude2) => {
3073
+ files2.map((f) => {
3074
+ const sourceFile = path.resolve(source2, f.name);
3075
+ const destFile = path.resolve(dest2, f.name);
3076
+ const fileExcluded = exclude2.includes(f.name);
3077
+ if (isFile(sourceFile) && !fileExcluded) {
3078
+ logger.debug(`[publish:static] Copying files from ${sourceFile} to ${destFile} excluding ${exclude2.join(",")}...`);
3079
+ fs.copyFileSync(sourceFile, destFile);
3080
+ logger.debug(`[publish:static] Copying files from ${sourceFile} to ${destFile} excluding ${exclude2.join(",")}...DONE!`);
3081
+ }
3082
+ });
3083
+ dirs2.map((d) => {
3084
+ const sourceDir = path.resolve(source2, d.name);
3085
+ const destDir = path.resolve(dest2, d.name);
3086
+ copyDir(sourceDir, destDir, exclude2);
3087
+ });
3088
+ })(paths, dirs, files, exclude);
3089
+ }
3090
+ }, "copyDir");
3091
+ try {
3092
+ const exclude = [
3093
+ "package.json",
3094
+ "node_modules",
3095
+ ".DS_Store"
3096
+ ];
3097
+ logger.info(`[create] Copying files from ${source} to ${dest} excluding ${exclude.join(",")}...`);
3098
+ copyDir(source, dest, typeof exclude !== "undefined" ? exclude : []);
3099
+ resolve();
3100
+ } catch (e) {
3101
+ logger.warn(`Something went wrong trying to publish static files: ${e.message}`);
3102
+ reject(e);
3103
+ }
3104
+ });
3105
+ }
3106
+ initCommand() {
3107
+ const switchCommander = this;
3108
+ if (process.argv.length > 1) {
3109
+ logger.debug("Installing Commands...");
3110
+ switchCommander.program.version(global.__get_version_string__());
3111
+ switchCommander.program.command("create <appname>").description("Creates an app with <appname>").option("--pwa, --create-pwa", "Creates the progressive web app assets").option("--amp, --create-amp", "Creates the accelerated mobile pages assets").option("--php, --create-php", "Creates the PWA PHP assets").option("--custom, --create-custom <templateappname>", "Creates an App from any NPM package template").option("--tests, --create-tests", "Creates the test suite").action(function(args, options) {
3112
+ switchCommander.choiceOption.create.call(switchCommander, args, options);
3113
+ });
3114
+ try {
3115
+ logger.debug("Loading Plugin Commands...");
3116
+ const importPluginCommands = /* @__PURE__ */ __name(function(switchCommander2) {
3117
+ return global.ClassesList.filter((c) => c.packageName.startsWith("com.qcobjects.cli.commands.")).filter((p) => p.classFactory.name.endsWith("CommandHandler")).map((pluginCommand) => {
3118
+ try {
3119
+ logger.debug(`Loading plugin ${pluginCommand.packageName}`);
3120
+ const classFactory = pluginCommand.classFactory;
3121
+ pluginCommand.plugin = New(classFactory, { switchCommander: switchCommander2 });
3122
+ } catch (e) {
3123
+ throw Error(`Something went wrong loading ${pluginCommand.packageName}`);
3124
+ }
3125
+ return pluginCommand;
3126
+ });
3127
+ }, "importPluginCommands");
3128
+ importPluginCommands(switchCommander);
3129
+ } catch (e) {
3130
+ throw Error(`Something went wrong loading plugins: ${e.message}`);
3131
+ }
3132
+ switchCommander.program.command("publish <appname>").description("Publishes an app with <appname>").option("--pwa, --create-pwa", "Publishes the progressive web app assets").option("--amp, --create-amp", "Publishes the accelerated mobile pages assets").option("--php, --create-php", "Creates the PWA PHP assets").option("--custom, --create-custom", "Creates an App from any NPM package template").option("--tests, --create-tests", "Publishes the test suite").action((args, options) => {
3133
+ switchCommander.choiceOption.publish.bind(switchCommander)(args, options);
3134
+ });
3135
+ switchCommander.program.command("upgrade-to-enterprise").description("Upgrades to QCObjects Enterprise Edition").action(function(args, options) {
3136
+ switchCommander.choiceOption.upgradeToEnterprise.call(switchCommander, args, options);
3137
+ });
3138
+ switchCommander.program.command("generate-sw <appname>").option("-d, --dir <dirPrefix> ", "creates the service worker in a specific dir <dirPrefix>").description("Generates the service worker <appname>").action(function(args, options) {
3139
+ switchCommander.choiceOption.generateSw.call(switchCommander, args, options);
3140
+ });
3141
+ switchCommander.program.command("launch <appname>").description("Launches the application").action(function(args, options) {
3142
+ logger.info("Launching...");
3143
+ setTimeout(() => {
3144
+ logger.info("Go to the browser and open https://localhost ");
3145
+ logger.info("Press Ctrl-C to stop serving ");
3146
+ exec("qcobjects-server", (err, stdout, stderr) => {
3147
+ }).stdout.on("data", function(data) {
3148
+ console.log(data);
3149
+ });
3150
+ }, 5e3);
3151
+ });
3152
+ switchCommander.program.on("--help", function() {
3153
+ console.log("");
3154
+ console.log("Use:");
3155
+ console.log(" $ qcobjects-cli [command] --help");
3156
+ console.log(" For detailed information of a command ");
3157
+ console.log("");
3158
+ process.exit(0);
3159
+ });
3160
+ switchCommander.program.on("command:*", function() {
3161
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", switchCommander.program.args.join(" "));
3162
+ process.exit(1);
3163
+ });
3164
+ switchCommander.program.parse(process.argv);
3165
+ } else {
3166
+ console.log("");
3167
+ console.log("Use:");
3168
+ console.log(" $ qcobjects-cli [command] --help");
3169
+ console.log(" For detailed information of a command ");
3170
+ console.log("");
3171
+ process.exit(0);
3172
+ }
3173
+ }
3174
+ };
3175
+ Package("org.quickcorp.qcobjects.cli", [
3176
+ SwitchCommander
3177
+ ]);
3178
+ exports = { SwitchCommander };
3179
+ }
3180
+ });
3181
+ export default require_org_quickcorp_qcobjects_cli();
3182
+ //# sourceMappingURL=org.quickcorp.qcobjects.cli.mjs.map