вывод только определенных System.property
This commit is contained in:
@@ -5,6 +5,4 @@ import org.jline.builtins.CommandRegistry;
|
|||||||
public interface CommandService extends CommandRegistry {
|
public interface CommandService extends CommandRegistry {
|
||||||
|
|
||||||
void register(String commandName, Command command);
|
void register(String commandName, Command command);
|
||||||
|
|
||||||
Object execute(CommandSession session, String commandName);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,17 +3,26 @@ package mc.server.shell;
|
|||||||
import org.jline.builtins.Builtins.CommandInput;
|
import org.jline.builtins.Builtins.CommandInput;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class SystemPropertiesCommand implements Command {
|
public class SystemPropertiesCommand implements Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandInput input) {
|
public void execute(CommandInput input) {
|
||||||
final PrintWriter writer = input.terminal().writer();
|
final PrintWriter writer = input.terminal().writer();
|
||||||
|
Stream<Map.Entry<Object, Object>> stream = System.getProperties().entrySet().stream();
|
||||||
|
|
||||||
final String[] args = input.args();
|
if (input.args().length > 0) {
|
||||||
writer.printf("args = [%s]\n", String.join(", ", args));
|
final List<String> argv = Arrays.asList(input.args());
|
||||||
|
stream = stream.filter(entry -> {
|
||||||
|
//noinspection SuspiciousMethodCalls
|
||||||
|
return argv.contains(entry.getKey());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
System.getProperties().forEach((key, value) ->
|
stream.forEach(entry -> writer.printf("%s = %s\n", entry.getKey(), entry.getValue().toString()));
|
||||||
writer.printf("%s = %s\n", key, value.toString()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user