Skip to content

Commit c172c62

Browse files
ggreifclaude
andcommitted
fix(motoko): enforce useDfx/useIcp mutual exclusivity
Throw IllegalArgumentException in processOpts() when both flags are set. Update CLI option descriptions to document the constraint. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b6fff64 commit c172c62

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/MotokoClientCodegen.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ public MotokoClientCodegen() {
147147
typeMapping.put("AnyType", "Text");
148148

149149
cliOptions.add(CliOption.newString(PROJECT_NAME, "Project name for generated code"));
150-
cliOptions.add(CliOption.newBoolean(USE_DFX, "Generate code for dfx with ic:aaaaa-aa imports", useDfx));
151-
cliOptions.add(CliOption.newBoolean(USE_ICP, "Generate icp.yaml for deployment with icp-cli (canary; replaces dfx)", useIcp));
150+
cliOptions.add(CliOption.newBoolean(USE_DFX, "Use ic:aaaaa-aa imports (dfx toolchain). Mutually exclusive with useIcp.", useDfx));
151+
cliOptions.add(CliOption.newBoolean(USE_ICP, "Use ic:aaaaa-aa imports and generate icp.yaml (icp-cli toolchain; replaces dfx). Mutually exclusive with useDfx.", useIcp));
152152

153153
// Enable inline enum resolution to create model files for inline enum parameters
154154
// This ensures type-safe enum variants instead of raw Text types
@@ -171,6 +171,9 @@ public void processOpts() {
171171
if (additionalProperties.containsKey(USE_ICP)) {
172172
setUseIcp(convertPropertyToBooleanAndWriteBack(USE_ICP));
173173
}
174+
if (useDfx && useIcp) {
175+
throw new IllegalArgumentException("useDfx and useIcp are mutually exclusive — pick one toolchain");
176+
}
174177
additionalProperties.put(USE_ICP, useIcp);
175178
if (useIcp) {
176179
supportingFiles.add(new SupportingFile("icp.yaml.mustache", "", "icp.yaml"));

0 commit comments

Comments
 (0)