forked from openclaw/openclaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig-set-parser.ts
More file actions
43 lines (41 loc) · 1.26 KB
/
Copy pathconfig-set-parser.ts
File metadata and controls
43 lines (41 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
type ConfigSetMode = "value" | "json" | "ref_builder" | "provider_builder" | "batch";
type ConfigSetModeResolution =
| {
ok: true;
mode: ConfigSetMode;
}
| {
ok: false;
error: string;
};
export function resolveConfigSetMode(params: {
hasBatchMode: boolean;
hasRefBuilderOptions: boolean;
hasProviderBuilderOptions: boolean;
strictJson: boolean;
}): ConfigSetModeResolution {
if (params.hasBatchMode) {
if (params.hasRefBuilderOptions || params.hasProviderBuilderOptions) {
return {
ok: false,
error:
"batch mode (--batch-json/--batch-file) cannot be combined with ref builder (--ref-*) or provider builder (--provider-*) flags.",
};
}
return { ok: true, mode: "batch" };
}
if (params.hasRefBuilderOptions && params.hasProviderBuilderOptions) {
return {
ok: false,
error:
"choose exactly one mode: ref builder (--ref-provider/--ref-source/--ref-id) or provider builder (--provider-*), not both.",
};
}
if (params.hasRefBuilderOptions) {
return { ok: true, mode: "ref_builder" };
}
if (params.hasProviderBuilderOptions) {
return { ok: true, mode: "provider_builder" };
}
return { ok: true, mode: params.strictJson ? "json" : "value" };
}