From 10c2c965a1e27e6a8b13cc7044bcbfb609f77f59 Mon Sep 17 00:00:00 2001 From: Remko Popma Date: Wed, 29 Apr 2020 15:16:36 +0900 Subject: [PATCH] [#1010] (work in progress) plan for making CommandSpec.copy robust against programmatic changes --- src/main/java/picocli/CommandLine.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/picocli/CommandLine.java b/src/main/java/picocli/CommandLine.java index 466650ad6..92eeb7388 100644 --- a/src/main/java/picocli/CommandLine.java +++ b/src/main/java/picocli/CommandLine.java @@ -5431,7 +5431,20 @@ private CommandSpec copy() { // TODO if this CommandSpec was created/modified via the programmatic API, // we need to copy all attributes that are modifiable via the programmatic API // and point them to this CommandSpec instance. - +// result.commands.clear(); result.commands.putAll(this.commands); +// result.optionsByNameMap.clear(); result.optionsByNameMap.putAll(this.optionsByNameMap); +// result.negatedOptionsByNameMap.clear(); result.negatedOptionsByNameMap.putAll(this.negatedOptionsByNameMap); +// result.posixOptionsByKeyMap.clear(); result.posixOptionsByKeyMap.putAll(this.posixOptionsByKeyMap); +// result.mixins.clear(); result.mixins.putAll(this.mixins); +// result.mixinAnnotatedElements.clear(); result.mixinAnnotatedElements.putAll(this.mixinAnnotatedElements); +// result.requiredArgs.clear(); result.requiredArgs.addAll(requiredArgs); +// result.args.clear(); result.args.addAll(args); +// result.options.clear(); result.options.addAll(options); +// result.positionalParameters.clear(); result.positionalParameters.addAll(positionalParameters); +// result.unmatchedArgs.clear(); result.unmatchedArgs.addAll(unmatchedArgs); +// result.specElements.clear(); result.specElements.addAll(specElements); +// result.parentCommandElements.clear(); result.parentCommandElements.addAll(parentCommandElements); +// result.groups.clear(); result.groups.addAll(groups); return result; }