Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<fix>(command): fix jline completion not contain all features key. #837

Merged
merged 1 commit into from
Mar 15, 2024
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies {
exclude group: "org.slf4j"
}
implementation('commons-cli:commons-cli:1.5.0')
implementation('org.jline:jline:3.25.0')
implementation('org.jline:jline:3.21.0')
implementation('io.bretty:console-table-builder:1.2')
implementation('com.github.jsqlparser:jsqlparser:2.0')
implementation('org.fisco-bcos.code-generator:bcos-code-generator:1.5.0-SNAPSHOT') {
Expand Down
77 changes: 35 additions & 42 deletions src/main/java/console/command/JlineUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import org.fisco.bcos.sdk.v3.client.Client;
import org.fisco.bcos.sdk.v3.client.protocol.response.BcosGroupInfo;
import org.fisco.bcos.sdk.v3.contract.precompiled.sysconfig.SystemConfigFeature;
import org.fisco.bcos.sdk.v3.contract.precompiled.sysconfig.SystemConfigService;
import org.fisco.bcos.sdk.v3.model.EnumNodeVersion;
Expand Down Expand Up @@ -183,50 +187,39 @@ private static List<Completer> generateComplters(Client client) {
if (client.isEnableCommittee()) {
commands.add(AuthOpCommand.SET_SYS_CONFIG_PROPOSAL.getCommand());
}
Set<String> keys = new HashSet<>();
keys.add(SystemConfigService.TX_COUNT_LIMIT);
keys.add(SystemConfigService.TX_GAS_LIMIT);
keys.add(SystemConfigService.TX_GAS_PRICE);
keys.add(SystemConfigService.CONSENSUS_PERIOD);
keys.add(SystemConfigService.COMPATIBILITY_VERSION);
keys.add(SystemConfigService.AUTH_STATUS);
for (SystemConfigFeature.Features feature : SystemConfigFeature.Features.values()) {
if (client.getChainCompatibilityVersion()
.compareTo(EnumNodeVersion.convertToVersion(feature.enableVersion()))
>= 0) {
keys.add(feature.toString());
}
}
Optional<BcosGroupInfo.GroupInfo> group =
client.getGroupInfoList()
.getResult()
.stream()
.filter(groupInfo -> groupInfo.getGroupID().equals(client.getGroup()))
.findFirst();
if (group.isPresent() && !group.get().getNodeList().isEmpty()) {
group.get()
.getNodeList()
.forEach(groupNodeInfo -> keys.addAll(groupNodeInfo.getFeatureKeys()));
}

for (String command : commands) {
completers.add(
new ArgumentCompleter(
new StringsCompleter(command),
new StringsCompleter(SystemConfigService.TX_COUNT_LIMIT),
new StringsCompleterIgnoreCase()));

completers.add(
new ArgumentCompleter(
new StringsCompleter(command),
new StringsCompleter(SystemConfigService.TX_GAS_LIMIT),
new StringsCompleterIgnoreCase()));
completers.add(
new ArgumentCompleter(
new StringsCompleter(command),
new StringsCompleter(SystemConfigService.TX_GAS_PRICE),
new StringsCompleterIgnoreCase()));
completers.add(
new ArgumentCompleter(
new StringsCompleter(command),
new StringsCompleter(SystemConfigService.CONSENSUS_PERIOD),
new StringsCompleterIgnoreCase()));
completers.add(
new ArgumentCompleter(
new StringsCompleter(command),
new StringsCompleter(SystemConfigService.COMPATIBILITY_VERSION),
new StringsCompleterIgnoreCase()));
completers.add(
new ArgumentCompleter(
new StringsCompleter(command),
new StringsCompleter(SystemConfigService.AUTH_STATUS),
new StringsCompleterIgnoreCase()));
for (SystemConfigFeature.Features feature : SystemConfigFeature.Features.values()) {
if (client.getChainCompatibilityVersion()
.compareTo(
EnumNodeVersion.convertToVersion(feature.enableVersion()))
>= 0) {
completers.add(
new ArgumentCompleter(
new StringsCompleter(command),
new StringsCompleter(feature.toString()),
new StringsCompleterIgnoreCase()));
}
for (String key : keys) {
completers.add(
new ArgumentCompleter(
new StringsCompleter(command),
new StringsCompleter(key),
new StringsCompleterIgnoreCase()));
}
}
completers.add(
Expand Down
Loading