Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
@CommandLine.Command(
name = "migrate-database",
description = "Migrate the database to a specified version.",
subcommands = {UnstableOptionsCommand.class},
mixinStandardHelpOptions = true,
abbreviateSynopsis = true,
versionProvider = PicoCliVersionProvider.class,
Expand Down Expand Up @@ -86,7 +87,10 @@ public class MigrateDatabaseCommand implements Runnable {
paramLabel = "<format>",
hidden = true,
description =
"The target database version to migrate to. 4, 5, 6 (RocksDB), leveldb1, leveldb2",
"""
The target database version to migrate to.
Rocksdb database types supported are 4, 5, 6.
Leveldb types supported are leveldb1, leveldb2.""",
arity = "1")
private String toDbVersion = DatabaseVersion.V6.getValue();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
package tech.pegasys.teku.cli.subcommand;

import java.io.PrintWriter;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import picocli.CommandLine;
import picocli.CommandLine.Help.ColorScheme;
import picocli.CommandLine.Model.CommandSpec;
Expand Down Expand Up @@ -59,6 +61,19 @@ public void run() {
optionsByModuleName.put(
argSpec.heading().replace("%n", ""), argSpec.allOptionsNested()));
commandSpec.mixins().forEach((name, spec) -> optionsByModuleName.put(name, spec.options()));

// Collect options already covered by mixins and arg groups
final Set<OptionSpec> alreadyCovered = new HashSet<>();
commandSpec.mixins().values().forEach(spec -> alreadyCovered.addAll(spec.options()));
commandSpec.argGroups().forEach(ag -> alreadyCovered.addAll(ag.allOptionsNested()));

// Include any hidden options defined directly on the command class itself
final List<OptionSpec> directOptions =
commandSpec.options().stream().filter(opt -> !alreadyCovered.contains(opt)).toList();
if (!directOptions.isEmpty()) {
optionsByModuleName.put(commandSpec.name(), directOptions);
}

optionsByModuleName.forEach(this::printUnstableOptions);
}

Expand Down
Loading