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