@catheadowl/ukp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +208 -0
- package/bun.lock +35 -0
- package/package.json +51 -0
- package/src/artifacts.ts +75 -0
- package/src/capabilities/nav.ts +734 -0
- package/src/capabilities/propose.ts +456 -0
- package/src/capabilities/qmd.ts +174 -0
- package/src/capabilities/read.ts +1040 -0
- package/src/capabilities/remote-client.ts +856 -0
- package/src/capabilities/rename-recovery.ts +294 -0
- package/src/capabilities/rg.ts +505 -0
- package/src/capabilities/search.ts +1105 -0
- package/src/capabilities/tls-identity.ts +87 -0
- package/src/capabilities/update.ts +385 -0
- package/src/cli.ts +425 -0
- package/src/commands/diagnose.ts +383 -0
- package/src/commands/flags.ts +49 -0
- package/src/commands/guide-content/client.txt +36 -0
- package/src/commands/guide-content/propose.txt +38 -0
- package/src/commands/guide-content/service-qmd.txt +44 -0
- package/src/commands/guide-content/service.txt +114 -0
- package/src/commands/guide.ts +121 -0
- package/src/commands/init.ts +245 -0
- package/src/commands/inspect.ts +182 -0
- package/src/commands/inventory.ts +570 -0
- package/src/commands/kit.ts +269 -0
- package/src/commands/nav.ts +280 -0
- package/src/commands/propose.ts +257 -0
- package/src/commands/read.ts +558 -0
- package/src/commands/rg.ts +355 -0
- package/src/commands/search.ts +325 -0
- package/src/commands/serve.ts +221 -0
- package/src/commands/update.ts +99 -0
- package/src/config/client.ts +55 -0
- package/src/config/external-tool.ts +58 -0
- package/src/config/file-native.ts +111 -0
- package/src/config/manifest.ts +188 -0
- package/src/fslock.ts +95 -0
- package/src/path-safety.ts +65 -0
- package/src/registry.ts +436 -0
- package/src/scope.ts +78 -0
- package/src/server.ts +1011 -0
- package/tsconfig.json +12 -0
package/src/cli.ts
ADDED
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import {
|
|
8
|
+
executeDiagnoseCommand,
|
|
9
|
+
DIAGNOSE_SPEC,
|
|
10
|
+
type ProviderResolver,
|
|
11
|
+
} from "./commands/diagnose.ts";
|
|
12
|
+
import { executeReadCommand, READ_SPEC } from "./commands/read.ts";
|
|
13
|
+
import { executeRgCommand, RG_SPEC } from "./commands/rg.ts";
|
|
14
|
+
import { executeGuideCommand, GUIDE_SPEC, GUIDE_TOPICS } from "./commands/guide.ts";
|
|
15
|
+
import { executeInitCommand, INIT_SPEC } from "./commands/init.ts";
|
|
16
|
+
import { executeInspectCommand, INSPECT_SPEC } from "./commands/inspect.ts";
|
|
17
|
+
import { executeListCommand, executeRegisterCommand, executeUnregisterCommand, LIST_SPEC, REGISTER_SPEC, UNREGISTER_SPEC } from "./commands/inventory.ts";
|
|
18
|
+
import { executeNavCommand, NAV_SPEC } from "./commands/nav.ts";
|
|
19
|
+
import { executeProposeCommand, PROPOSE_SPEC } from "./commands/propose.ts";
|
|
20
|
+
import { executeUpdateCommand, UPDATE_SPEC } from "./commands/update.ts";
|
|
21
|
+
import { executeServeCommand, SERVE_SPEC } from "./commands/serve.ts";
|
|
22
|
+
import { executeSearchCommand, SEARCH_SPEC } from "./commands/search.ts";
|
|
23
|
+
|
|
24
|
+
export { renderSearchHelp } from "./commands/search.ts";
|
|
25
|
+
export { renderDiagnoseHelp } from "./commands/diagnose.ts";
|
|
26
|
+
export { renderReadHelp } from "./commands/read.ts";
|
|
27
|
+
export { renderGuideHelp, renderServiceGuide, renderServiceQmdGuide, renderClientGuide, renderProposeGuide } from "./commands/guide.ts";
|
|
28
|
+
export { renderInitHelp, renderInitServiceHelp } from "./commands/init.ts";
|
|
29
|
+
export { renderInspectHelp } from "./commands/inspect.ts";
|
|
30
|
+
export { renderUpdateHelp } from "./commands/update.ts";
|
|
31
|
+
export { renderProposeHelp } from "./commands/propose.ts";
|
|
32
|
+
export { renderNavHelp } from "./commands/nav.ts";
|
|
33
|
+
export { renderRgHelp } from "./commands/rg.ts";
|
|
34
|
+
|
|
35
|
+
// `get` was renamed to `read`; with no external users the old
|
|
36
|
+
// spelling was removed outright instead of kept as an alias.
|
|
37
|
+
//
|
|
38
|
+
// Command descriptions are the single source; COMMAND_GROUPS only assigns
|
|
39
|
+
// each command a help-display heading (ADR 0022). Grouping is a rendering
|
|
40
|
+
// concern: the invocation surface stays flat — `ukp <verb>` — and dispatch
|
|
41
|
+
// in runCli is unchanged.
|
|
42
|
+
const COMMAND_DESCRIPTIONS: Record<string, string> = {
|
|
43
|
+
// ADR 0024: migrated commands feed their root-help summary from the
|
|
44
|
+
// command spec; `version` stays hand-written (meta command, deliberate
|
|
45
|
+
// exception — no usage string, custom help handling).
|
|
46
|
+
diagnose: DIAGNOSE_SPEC.summary,
|
|
47
|
+
read: READ_SPEC.summary,
|
|
48
|
+
rg: RG_SPEC.summary,
|
|
49
|
+
guide: GUIDE_SPEC.summary,
|
|
50
|
+
init: INIT_SPEC.summary,
|
|
51
|
+
inspect: INSPECT_SPEC.summary,
|
|
52
|
+
serve: SERVE_SPEC.summary,
|
|
53
|
+
update: UPDATE_SPEC.summary,
|
|
54
|
+
register: REGISTER_SPEC.summary,
|
|
55
|
+
unregister: UNREGISTER_SPEC.summary,
|
|
56
|
+
list: LIST_SPEC.summary,
|
|
57
|
+
nav: NAV_SPEC.summary,
|
|
58
|
+
propose: PROPOSE_SPEC.summary,
|
|
59
|
+
search: SEARCH_SPEC.summary,
|
|
60
|
+
version: "show version information",
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const COMMANDS = Object.entries(COMMAND_DESCRIPTIONS).map(
|
|
64
|
+
([name, description]) => [name, description] as const,
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
// Help-display groups (ADR 0022): purpose-noun headings over a flat verb
|
|
68
|
+
// surface. Every command must appear in exactly one group; a guard test
|
|
69
|
+
// locks group membership against COMMANDS.
|
|
70
|
+
export const COMMAND_GROUPS = [
|
|
71
|
+
{
|
|
72
|
+
heading: "Endpoint commands",
|
|
73
|
+
commands: ["search", "read", "nav", "rg", "propose"],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
heading: "Registry commands",
|
|
77
|
+
commands: ["init", "register", "unregister", "list"],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
heading: "Operations commands",
|
|
81
|
+
commands: ["diagnose", "inspect", "update", "serve"],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
heading: "Help commands",
|
|
85
|
+
commands: ["guide", "version"],
|
|
86
|
+
},
|
|
87
|
+
] as const;
|
|
88
|
+
|
|
89
|
+
export interface CliContext {
|
|
90
|
+
currentDirectory?: string;
|
|
91
|
+
registryPath?: string;
|
|
92
|
+
resolveProvider?: ProviderResolver;
|
|
93
|
+
qmdCommand?: readonly string[];
|
|
94
|
+
rgCommand?: readonly string[];
|
|
95
|
+
artifactRoot?: string;
|
|
96
|
+
artifactRunId?: string;
|
|
97
|
+
now?: Date;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
interface CliCommandResult {
|
|
101
|
+
exitCode: number;
|
|
102
|
+
stdout: string;
|
|
103
|
+
stderr: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
interface PackageMetadata {
|
|
107
|
+
version?: unknown;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const PACKAGE_JSON_URL = new URL("../package.json", import.meta.url);
|
|
111
|
+
const SOURCE_ROOT_URL = new URL("./", import.meta.url);
|
|
112
|
+
const PACKAGE_JSON_PATH = fileURLToPath(PACKAGE_JSON_URL);
|
|
113
|
+
const SOURCE_ROOT_PATH = dirname(fileURLToPath(import.meta.url));
|
|
114
|
+
|
|
115
|
+
function readPackageVersion(): string {
|
|
116
|
+
const packageJson = JSON.parse(
|
|
117
|
+
readFileSync(PACKAGE_JSON_URL, "utf8"),
|
|
118
|
+
) as PackageMetadata;
|
|
119
|
+
|
|
120
|
+
if (typeof packageJson.version !== "string" || packageJson.version.length === 0) {
|
|
121
|
+
throw new Error("version metadata must contain a non-empty version string");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return packageJson.version;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function findLatestMtimeMs(root: URL): number {
|
|
128
|
+
const stat = statSync(root);
|
|
129
|
+
if (!stat.isDirectory()) return stat.mtimeMs;
|
|
130
|
+
|
|
131
|
+
return readdirSync(root, { withFileTypes: true }).reduce((latest, entry) => {
|
|
132
|
+
const child = new URL(`${entry.name}${entry.isDirectory() ? "/" : ""}`, root);
|
|
133
|
+
return Math.max(latest, findLatestMtimeMs(child));
|
|
134
|
+
}, stat.mtimeMs);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function formatMtime(ms: number): string {
|
|
138
|
+
return new Date(ms).toISOString();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function formatLocalMtime(ms: number): string {
|
|
142
|
+
return new Date(ms).toLocaleString(undefined, {
|
|
143
|
+
year: "numeric",
|
|
144
|
+
month: "2-digit",
|
|
145
|
+
day: "2-digit",
|
|
146
|
+
hour: "2-digit",
|
|
147
|
+
minute: "2-digit",
|
|
148
|
+
second: "2-digit",
|
|
149
|
+
timeZoneName: "short",
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function renderVersion(options: { verbose?: boolean } = {}): string {
|
|
154
|
+
const version = readPackageVersion();
|
|
155
|
+
if (!options.verbose) return `ukp ${version}\n`;
|
|
156
|
+
|
|
157
|
+
const packageMtimeMs = statSync(PACKAGE_JSON_URL).mtimeMs;
|
|
158
|
+
const sourceMtimeMs = findLatestMtimeMs(SOURCE_ROOT_URL);
|
|
159
|
+
const lines = [
|
|
160
|
+
`ukp ${version}`,
|
|
161
|
+
`source_updated_local: ${formatLocalMtime(sourceMtimeMs)}`,
|
|
162
|
+
`source_updated_utc: ${formatMtime(sourceMtimeMs)}`,
|
|
163
|
+
`package_updated_local: ${formatLocalMtime(packageMtimeMs)}`,
|
|
164
|
+
`package_updated_utc: ${formatMtime(packageMtimeMs)}`,
|
|
165
|
+
`runtime: bun ${Bun.version}`,
|
|
166
|
+
`source: ${SOURCE_ROOT_PATH}`,
|
|
167
|
+
`package: ${PACKAGE_JSON_PATH}`,
|
|
168
|
+
];
|
|
169
|
+
return `${lines.join("\n")}\n`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function renderVersionHelp(): string {
|
|
173
|
+
const lines = [
|
|
174
|
+
"Usage: ukp version [options]",
|
|
175
|
+
"",
|
|
176
|
+
"Show version information.",
|
|
177
|
+
"",
|
|
178
|
+
"Options:",
|
|
179
|
+
" -v, --verbose show debug version details",
|
|
180
|
+
" -h, --help show this help",
|
|
181
|
+
];
|
|
182
|
+
return `${lines.join("\n")}\n`;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export function renderHelp(): string {
|
|
186
|
+
const lines = [
|
|
187
|
+
"Usage: ukp <command> [options]",
|
|
188
|
+
"",
|
|
189
|
+
"Start here: 'ukp guide service' (first setup — covers init and register) or 'ukp list' (see registered endpoints).",
|
|
190
|
+
"",
|
|
191
|
+
"Commands:",
|
|
192
|
+
...COMMAND_GROUPS.flatMap((group) => [
|
|
193
|
+
`${group.heading}:`,
|
|
194
|
+
...group.commands.map((name) =>
|
|
195
|
+
` ${name.padEnd(10)} ${COMMAND_DESCRIPTIONS[name]}`
|
|
196
|
+
),
|
|
197
|
+
"",
|
|
198
|
+
]),
|
|
199
|
+
"Endpoint names for --endpoint come from 'ukp list'.",
|
|
200
|
+
"",
|
|
201
|
+
"A Service's declared capabilities are backed by a provider (QMD backs search and update today); rg and nav work on endpoint files directly, no provider needed.",
|
|
202
|
+
"",
|
|
203
|
+
"A Service is a folder with a manifest (a name plus optional declared capabilities); registering it binds that name as an endpoint you address with --endpoint. The scope is which endpoints commands use when no --endpoint or -g (every registered endpoint) is given; 'ukp guide client' shows how to set the workspace default.",
|
|
204
|
+
"",
|
|
205
|
+
"Guides:",
|
|
206
|
+
...GUIDE_TOPICS.map(([topic, summary]) => ` ukp ${`guide ${topic}`.padEnd(17)} ${summary}`),
|
|
207
|
+
"",
|
|
208
|
+
"Options:",
|
|
209
|
+
" -h, --help show this help",
|
|
210
|
+
" -V, --version show version",
|
|
211
|
+
];
|
|
212
|
+
return `${lines.join("\n")}\n`;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function writeCommandResult(
|
|
216
|
+
result: CliCommandResult,
|
|
217
|
+
stdout: (message?: unknown) => void,
|
|
218
|
+
stderr: (message?: unknown) => void,
|
|
219
|
+
): number {
|
|
220
|
+
if (result.stdout) stdout(result.stdout.trimEnd());
|
|
221
|
+
if (result.stderr) stderr(result.stderr.trimEnd());
|
|
222
|
+
return result.exitCode;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function executeVersionCommand(args: readonly string[]): CliCommandResult {
|
|
226
|
+
if (args.length === 0) {
|
|
227
|
+
return { exitCode: 0, stdout: renderVersion(), stderr: "" };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Help wins wherever it appears (option order-independence; same rule as
|
|
231
|
+
// the commander-wrapped commands via isCommanderHelpIntent).
|
|
232
|
+
if (args.includes("-h") || args.includes("--help")) {
|
|
233
|
+
return { exitCode: 0, stdout: renderVersionHelp(), stderr: "" };
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (args.length === 1 && (args[0] === "-v" || args[0] === "--verbose")) {
|
|
237
|
+
return { exitCode: 0, stdout: renderVersion({ verbose: true }), stderr: "" };
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return {
|
|
241
|
+
exitCode: 2,
|
|
242
|
+
stdout: "",
|
|
243
|
+
stderr: [
|
|
244
|
+
`ukp version: unexpected argument '${args[0] ?? ""}'`,
|
|
245
|
+
"Run 'ukp version --help' for details.",
|
|
246
|
+
].join("\n"),
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function writeVersionCommandResult(
|
|
251
|
+
createResult: () => CliCommandResult,
|
|
252
|
+
stdout: (message?: unknown) => void,
|
|
253
|
+
stderr: (message?: unknown) => void,
|
|
254
|
+
): number {
|
|
255
|
+
try {
|
|
256
|
+
return writeCommandResult(createResult(), stdout, stderr);
|
|
257
|
+
} catch (error) {
|
|
258
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
259
|
+
stderr(`ukp: unable to read version metadata: ${message}`);
|
|
260
|
+
return 1;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Conditional-async dispatch shim (ukp_remote W2): local-only invocations
|
|
265
|
+
* stay fully synchronous (returning a number); scopes that include remote
|
|
266
|
+
* endpoints resolve over the network and return a promise. The bin entry
|
|
267
|
+
* awaits promises; sync callers (tests) see numbers unchanged. */
|
|
268
|
+
function writeCommandResultMaybeAsync(
|
|
269
|
+
result: CliCommandResult | Promise<CliCommandResult>,
|
|
270
|
+
stdout: (message?: unknown) => void,
|
|
271
|
+
stderr: (message?: unknown) => void,
|
|
272
|
+
): number | Promise<number> {
|
|
273
|
+
if (result instanceof Promise) {
|
|
274
|
+
return result.then((resolved) => writeCommandResult(resolved, stdout, stderr));
|
|
275
|
+
}
|
|
276
|
+
return writeCommandResult(result, stdout, stderr);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export function runCli(
|
|
280
|
+
args: readonly string[],
|
|
281
|
+
stdout = console.log,
|
|
282
|
+
stderr = console.error,
|
|
283
|
+
context: CliContext = {},
|
|
284
|
+
): number | Promise<number> {
|
|
285
|
+
const [command] = args;
|
|
286
|
+
const currentDirectory = context.currentDirectory ?? process.cwd();
|
|
287
|
+
const registryPath = context.registryPath ?? join(homedir(), ".ukp", "registry.toml");
|
|
288
|
+
|
|
289
|
+
if (!command || command === "-h" || command === "--help") {
|
|
290
|
+
stdout(renderHelp().trimEnd());
|
|
291
|
+
return 0;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (command === "-V" || command === "--version") {
|
|
295
|
+
return writeVersionCommandResult(
|
|
296
|
+
() => ({ exitCode: 0, stdout: renderVersion(), stderr: "" }),
|
|
297
|
+
stdout,
|
|
298
|
+
stderr,
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (command === "version") {
|
|
303
|
+
return writeVersionCommandResult(() => executeVersionCommand(args.slice(1)), stdout, stderr);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (command === "diagnose") {
|
|
307
|
+
return writeCommandResult(executeDiagnoseCommand(args.slice(1), {
|
|
308
|
+
currentDirectory,
|
|
309
|
+
registryPath,
|
|
310
|
+
resolveProvider: context.resolveProvider,
|
|
311
|
+
}), stdout, stderr);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (command === "read") {
|
|
315
|
+
return writeCommandResultMaybeAsync(executeReadCommand(args.slice(1), {
|
|
316
|
+
currentDirectory,
|
|
317
|
+
registryPath,
|
|
318
|
+
qmdCommand: context.qmdCommand,
|
|
319
|
+
}), stdout, stderr);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (command === "guide") {
|
|
323
|
+
return writeCommandResult(executeGuideCommand(args.slice(1)), stdout, stderr);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (command === "init") {
|
|
327
|
+
return writeCommandResult(executeInitCommand(args.slice(1), {
|
|
328
|
+
currentDirectory,
|
|
329
|
+
}), stdout, stderr);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (command === "inspect") {
|
|
333
|
+
return writeCommandResult(executeInspectCommand(args.slice(1), {
|
|
334
|
+
currentDirectory,
|
|
335
|
+
registryPath,
|
|
336
|
+
resolveProvider: context.resolveProvider,
|
|
337
|
+
}), stdout, stderr);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (command === "register") {
|
|
341
|
+
return writeCommandResultMaybeAsync(executeRegisterCommand(args.slice(1), {
|
|
342
|
+
currentDirectory,
|
|
343
|
+
registryPath,
|
|
344
|
+
resolveProvider: context.resolveProvider,
|
|
345
|
+
}), stdout, stderr);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if (command === "update") {
|
|
349
|
+
return writeCommandResult(executeUpdateCommand(args.slice(1), {
|
|
350
|
+
currentDirectory,
|
|
351
|
+
registryPath,
|
|
352
|
+
qmdCommand: context.qmdCommand,
|
|
353
|
+
}), stdout, stderr);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (command === "serve") {
|
|
357
|
+
return writeCommandResult(executeServeCommand(args.slice(1), {
|
|
358
|
+
currentDirectory,
|
|
359
|
+
registryPath,
|
|
360
|
+
qmdCommand: context.qmdCommand,
|
|
361
|
+
}), stdout, stderr);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (command === "unregister") {
|
|
365
|
+
return writeCommandResult(executeUnregisterCommand(args.slice(1), {
|
|
366
|
+
currentDirectory,
|
|
367
|
+
registryPath,
|
|
368
|
+
}), stdout, stderr);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if (command === "list") {
|
|
372
|
+
return writeCommandResultMaybeAsync(executeListCommand(args.slice(1), {
|
|
373
|
+
currentDirectory,
|
|
374
|
+
registryPath,
|
|
375
|
+
}), stdout, stderr);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (command === "nav") {
|
|
379
|
+
return writeCommandResultMaybeAsync(executeNavCommand(args.slice(1), {
|
|
380
|
+
currentDirectory,
|
|
381
|
+
registryPath,
|
|
382
|
+
}), stdout, stderr);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (command === "propose") {
|
|
386
|
+
return writeCommandResultMaybeAsync(executeProposeCommand(args.slice(1), {
|
|
387
|
+
currentDirectory,
|
|
388
|
+
registryPath,
|
|
389
|
+
}), stdout, stderr);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
if (command === "rg") {
|
|
393
|
+
return writeCommandResultMaybeAsync(executeRgCommand(args.slice(1), {
|
|
394
|
+
currentDirectory,
|
|
395
|
+
registryPath,
|
|
396
|
+
rgCommand: context.rgCommand,
|
|
397
|
+
}), stdout, stderr);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
if (command === "search") {
|
|
401
|
+
return writeCommandResultMaybeAsync(executeSearchCommand(args.slice(1), {
|
|
402
|
+
currentDirectory,
|
|
403
|
+
registryPath,
|
|
404
|
+
qmdCommand: context.qmdCommand,
|
|
405
|
+
artifactRoot: context.artifactRoot,
|
|
406
|
+
artifactRunId: context.artifactRunId,
|
|
407
|
+
now: context.now,
|
|
408
|
+
}), stdout, stderr);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
stderr(`ukp: unknown command '${command}'`);
|
|
412
|
+
stderr("Run 'ukp --help' for usage.");
|
|
413
|
+
return 2;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
if (import.meta.main) {
|
|
417
|
+
const exitCode = runCli(process.argv.slice(2));
|
|
418
|
+
if (exitCode instanceof Promise) {
|
|
419
|
+
exitCode.then((code) => {
|
|
420
|
+
process.exitCode = code;
|
|
421
|
+
});
|
|
422
|
+
} else {
|
|
423
|
+
process.exitCode = exitCode;
|
|
424
|
+
}
|
|
425
|
+
}
|