mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 00:50:21 +00:00
CLI: expand config set with SecretRef/provider builders and dry-run (#49296)
* CLI: expand config set ref/provider builder and dry-run * Docs: revert README Discord token example
This commit is contained in:
43
src/cli/config-set-parser.ts
Normal file
43
src/cli/config-set-parser.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
export type ConfigSetMode = "value" | "json" | "ref_builder" | "provider_builder" | "batch";
|
||||
|
||||
export 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" };
|
||||
}
|
||||
Reference in New Issue
Block a user