@norskvideo/ctl-commands 0.1.13 → 0.1.14
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/commands.d.ts +7 -2
- package/commands.js +13 -3
- package/format.js +8 -5
- package/package.json +1 -1
package/commands.d.ts
CHANGED
|
@@ -45,6 +45,11 @@ export interface ProxyLogsOpts {
|
|
|
45
45
|
}
|
|
46
46
|
export interface SourceStartOpts {
|
|
47
47
|
port?: number;
|
|
48
|
+
service?: string;
|
|
49
|
+
streamId?: string;
|
|
50
|
+
name?: string;
|
|
51
|
+
mediaFile?: string;
|
|
52
|
+
generate?: "bars" | "testsrc";
|
|
48
53
|
}
|
|
49
54
|
export interface StatsOpts {
|
|
50
55
|
output?: "table" | "yaml" | "json";
|
|
@@ -298,10 +303,10 @@ export declare const commands: {
|
|
|
298
303
|
readonly kind: "serve";
|
|
299
304
|
}>;
|
|
300
305
|
readonly source: {
|
|
301
|
-
readonly start: LeafCmd<(instanceId: string, preset: string, opts?: SourceStartOpts) => {
|
|
306
|
+
readonly start: LeafCmd<(instanceId: string, preset: string | undefined, opts?: SourceStartOpts) => {
|
|
302
307
|
readonly kind: "source.start";
|
|
303
308
|
readonly instanceId: string;
|
|
304
|
-
readonly preset: string;
|
|
309
|
+
readonly preset: string | undefined;
|
|
305
310
|
readonly opts: SourceStartOpts;
|
|
306
311
|
}>;
|
|
307
312
|
readonly stop: LeafCmd<(instanceId: string, name: string) => {
|
package/commands.js
CHANGED
|
@@ -25,8 +25,14 @@ function leaf(kind, fn, ...positionals) {
|
|
|
25
25
|
// segments, and it differs exactly by camelCase — the same transform the
|
|
26
26
|
// flag renderer applies.
|
|
27
27
|
const path = kind.split(".").map(camelToKebab);
|
|
28
|
-
const sig = [
|
|
29
|
-
|
|
28
|
+
const sig = [
|
|
29
|
+
path[path.length - 1],
|
|
30
|
+
...positionals.map((p) => {
|
|
31
|
+
const raw = String(p);
|
|
32
|
+
return raw.endsWith("?") ? `[${raw.slice(0, -1)}]` : `<${raw}>`;
|
|
33
|
+
}),
|
|
34
|
+
].join(" ");
|
|
35
|
+
specs.set(kind, { kind, path, positionals: positionals.map((p) => String(p).replace(/\?$/, "")) });
|
|
30
36
|
return Object.assign(fn, { __sig: sig });
|
|
31
37
|
}
|
|
32
38
|
/** Runtime source for the `get` vocabulary — the CLI's yargs `choices` and
|
|
@@ -95,7 +101,11 @@ export const commands = {
|
|
|
95
101
|
mcp: leaf("mcp", () => ({ kind: "mcp" })),
|
|
96
102
|
serve: leaf("serve", () => ({ kind: "serve" })),
|
|
97
103
|
source: {
|
|
98
|
-
start: leaf("source.start",
|
|
104
|
+
start: leaf("source.start",
|
|
105
|
+
// The asset may instead be named by flag (--media-file / --generate), so
|
|
106
|
+
// the preset positional is optional; the daemon refuses a request that
|
|
107
|
+
// names none or more than one.
|
|
108
|
+
(instanceId, preset, opts = {}) => ({ kind: "source.start", instanceId, preset, opts }), "instanceId", "preset?"),
|
|
99
109
|
stop: leaf("source.stop", (instanceId, name) => ({ kind: "source.stop", instanceId, name }), "instanceId", "name"),
|
|
100
110
|
list: leaf("source.list", () => ({ kind: "source.list" })),
|
|
101
111
|
presets: leaf("source.presets", () => ({ kind: "source.presets" })),
|
package/format.js
CHANGED
|
@@ -32,11 +32,14 @@ export function toArgv(cmd) {
|
|
|
32
32
|
if (!spec)
|
|
33
33
|
throw new Error(`toArgv: '${cmd.kind}' is not a declared command kind`);
|
|
34
34
|
const fields = cmd;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
];
|
|
35
|
+
// An omitted optional positional leaves no gap: trailing undefined slots are
|
|
36
|
+
// dropped rather than rendered, which would put the literal "undefined" where
|
|
37
|
+
// the shell expects a value. Only trailing ones — dropping a middle slot
|
|
38
|
+
// would silently shift every positional after it.
|
|
39
|
+
const positionals = spec.positionals.map((name) => fields[name]);
|
|
40
|
+
while (positionals.length > 0 && positionals[positionals.length - 1] === undefined)
|
|
41
|
+
positionals.pop();
|
|
42
|
+
return [...spec.path, ...positionals.map(String), ...formatOpts(fields.opts)];
|
|
40
43
|
}
|
|
41
44
|
export function commandToString(cmd) {
|
|
42
45
|
return ["norsk-ctl", ...toArgv(cmd)].join(" ");
|