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