Skip to content

Commit 29d4f88

Browse files
committed
clarified migrate-database help
Had to change UnstableOptions to allow Xhelp in migrate-database as well.
1 parent 260d0ae commit 29d4f88

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

teku/src/main/java/tech/pegasys/teku/cli/subcommand/MigrateDatabaseCommand.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
@CommandLine.Command(
3434
name = "migrate-database",
3535
description = "Migrate the database to a specified version.",
36+
subcommands = {UnstableOptionsCommand.class},
3637
mixinStandardHelpOptions = true,
3738
abbreviateSynopsis = true,
3839
versionProvider = PicoCliVersionProvider.class,
@@ -86,7 +87,9 @@ public class MigrateDatabaseCommand implements Runnable {
8687
paramLabel = "<format>",
8788
hidden = true,
8889
description =
89-
"The target database version to migrate to. 4, 5, 6 (RocksDB), leveldb1, leveldb2",
90+
"The target database version to migrate to. "
91+
+ "Rocksdb database types supported are 4, 5, 6. "
92+
+ "Leveldb types supported are leveldb1, leveldb2.",
9093
arity = "1")
9194
private String toDbVersion = DatabaseVersion.V6.getValue();
9295

teku/src/main/java/tech/pegasys/teku/cli/subcommand/UnstableOptionsCommand.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
package tech.pegasys.teku.cli.subcommand;
1515

1616
import java.io.PrintWriter;
17+
import java.util.HashSet;
1718
import java.util.LinkedHashMap;
1819
import java.util.List;
1920
import java.util.Map;
21+
import java.util.Set;
2022
import picocli.CommandLine;
2123
import picocli.CommandLine.Help.ColorScheme;
2224
import picocli.CommandLine.Model.CommandSpec;
@@ -59,6 +61,19 @@ public void run() {
5961
optionsByModuleName.put(
6062
argSpec.heading().replace("%n", ""), argSpec.allOptionsNested()));
6163
commandSpec.mixins().forEach((name, spec) -> optionsByModuleName.put(name, spec.options()));
64+
65+
// Collect options already covered by mixins and arg groups
66+
final Set<OptionSpec> alreadyCovered = new HashSet<>();
67+
commandSpec.mixins().values().forEach(spec -> alreadyCovered.addAll(spec.options()));
68+
commandSpec.argGroups().forEach(ag -> alreadyCovered.addAll(ag.allOptionsNested()));
69+
70+
// Include any hidden options defined directly on the command class itself
71+
final List<OptionSpec> directOptions =
72+
commandSpec.options().stream().filter(opt -> !alreadyCovered.contains(opt)).toList();
73+
if (!directOptions.isEmpty()) {
74+
optionsByModuleName.put(commandSpec.name(), directOptions);
75+
}
76+
6277
optionsByModuleName.forEach(this::printUnstableOptions);
6378
}
6479

0 commit comments

Comments
 (0)