diff options
Diffstat (limited to 'spark-common/src/main')
3 files changed, 15 insertions, 12 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/MemoryModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/MemoryModule.java index 405b3d3..6f748fb 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/MemoryModule.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/MemoryModule.java @@ -23,6 +23,7 @@ package me.lucko.spark.common.command.modules; import me.lucko.spark.common.SparkPlatform; import me.lucko.spark.common.command.Command; import me.lucko.spark.common.command.CommandModule; +import me.lucko.spark.common.command.tabcomplete.TabCompleter; import me.lucko.spark.memory.HeapDump; import me.lucko.spark.memory.HeapDumpSummary; @@ -72,6 +73,7 @@ public class MemoryModule<S> implements CommandModule<S> { } }); }) + .tabCompleter((platform, sender, arguments) -> TabCompleter.completeForOpts(arguments, "--run-gc-before")) .build() ); @@ -109,6 +111,7 @@ public class MemoryModule<S> implements CommandModule<S> { platform.sendPrefixedMessage("&bHeap dump written to: " + file.toString()); }); }) + .tabCompleter((platform, sender, arguments) -> TabCompleter.completeForOpts(arguments, "--run-gc-before", "--include-non-live")) .build() ); } diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/TickMonitoringModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/TickMonitoringModule.java index d0513ab..3ad8909 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/TickMonitoringModule.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/TickMonitoringModule.java @@ -23,14 +23,10 @@ package me.lucko.spark.common.command.modules; import me.lucko.spark.common.SparkPlatform; import me.lucko.spark.common.command.Command; import me.lucko.spark.common.command.CommandModule; -import me.lucko.spark.common.command.tabcomplete.CompletionSupplier; import me.lucko.spark.common.command.tabcomplete.TabCompleter; import me.lucko.spark.monitor.TickMonitor; import me.lucko.spark.sampler.TickCounter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import java.util.function.Consumer; public class TickMonitoringModule<S> implements CommandModule<S> { @@ -64,14 +60,7 @@ public class TickMonitoringModule<S> implements CommandModule<S> { platform.sendPrefixedMessage("&7Tick monitor disabled."); } }) - .tabCompleter((platform, sender, arguments) -> { - List<String> opts = new ArrayList<>(Arrays.asList("--threshold", "--without-gc")); - opts.removeAll(arguments); - - return TabCompleter.create() - .from(0, CompletionSupplier.startsWith(opts)) - .complete(arguments); - }) + .tabCompleter((platform, sender, arguments) -> TabCompleter.completeForOpts(arguments, "--threshold", "--without-gc")) .build() ); } diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/tabcomplete/TabCompleter.java b/spark-common/src/main/java/me/lucko/spark/common/command/tabcomplete/TabCompleter.java index f8774b2..d2b2622 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/tabcomplete/TabCompleter.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/tabcomplete/TabCompleter.java @@ -27,6 +27,8 @@ package me.lucko.spark.common.command.tabcomplete; import com.google.common.base.Preconditions; +import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -40,6 +42,15 @@ public class TabCompleter { return new TabCompleter(); } + public static List<String> completeForOpts(List<String> args, String... options) { + List<String> opts = new ArrayList<>(Arrays.asList(options)); + opts.removeAll(args); + + return TabCompleter.create() + .from(0, CompletionSupplier.startsWith(opts)) + .complete(args); + } + private final Map<Integer, CompletionSupplier> suppliers = new HashMap<>(); private int from = Integer.MAX_VALUE; |